-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
We are unable to use any tool_choice
besides 'auto' for GPT5 models in the Responses API using the latest release v.1.99.5.
Documentation:
- https://platform.openai.com/docs/guides/latest-model#allowed-tools
- https://platform.openai.com/docs/api-reference/responses/create#responses_create-tool_choice
BadRequestError: Error code: 400 - {'error': {'message': "Tool choices other than 'auto' are not supported with model 'gpt-5-mini-2025-08-07' and the following tool types: 'code_interpreter', 'file_search'.", 'type': 'invalid_request_error', 'param': 'tool_choice', 'code': None}}
Posts on community.openai.com:
- https://community.openai.com/t/error-400-tool-choices-other-than-auto-are-not-supported-with-model-gpt-5-and-the-following-tool-types-web-search-preview/1337152
- https://community.openai.com/t/gpt5-and-forced-web-search/1344079
- https://community.openai.com/t/gpt5-cannot-use-web-search-please-help/1337041
To Reproduce
stream = await llm.responses.create(
model="gpt-5",
input="Use your python tool to do this math: 8*9183*7663",
tools=[
{"type": "code_interpreter", "container": {"type": "auto"}},
],
tool_choice={
"type": "allowed_tools",
"mode": "auto",
"tools": [
{
"type": "code_interpreter",
}
],
},
stream=True,
)
async for event in stream:
print(event.model_dump_json(indent=2))
Code snippets
OS
Windows 11
Python version
Python 3.13.2
Library version
openai v.1.99.5