openai / openai/openai-python

GPT5 Models | Tool choices other than 'auto' are not supported with model

Open
#2,537 17 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api bug
Dominant language
Python
Stars
31.6k
Forks
5.7k
Avg merge
1d 6h
Merged PRs (30d)
96

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:
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:
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Responses API call in the reproduction and compare its allowed_tools tool_choice with the linked API documentation. Check whether the 400 response is caused by the Python library or the underlying API; done means the supported behavior and any required library change are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.