fix(openai): fix env var bool parsing and add responses API docs

- Use .lower() == "true" for LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES to avoid bool("False") == True bug
- Add clarifying comment on early return in responses_api_bridge_check
- Document route_all_chat_openai_to_responses flag in openai/responses_api.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sameer Kankute 2026-04-01 17:47:44 +05:30
parent 50861b4524
commit 6072d1b66e
No known key found for this signature in database
3 changed files with 43 additions and 3 deletions

View file

@ -923,6 +923,45 @@ curl http://localhost:4000/v1/chat/completions \
</TabItem>
</Tabs>
### Route all OpenAI chat completions through the Responses API (recommended)
Instead of prefixing each model with `openai/responses/`, you can enable a global flag to automatically route **all** `/chat/completions` requests for OpenAI models through the Responses API bridge. This is the recommended approach for OpenAI models.
<Tabs>
<TabItem value="sdk" label="LiteLLM Python SDK">
```python showLineNumbers title="Global flag - route all OpenAI completions via Responses API"
import litellm
litellm.route_all_chat_openai_to_responses = True
response = litellm.completion(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
```
</TabItem>
<TabItem value="proxy" label="LiteLLM Proxy">
```yaml showLineNumbers title="proxy_config.yaml"
litellm_settings:
route_all_chat_openai_to_responses: true
```
Or set via environment variable:
```bash
LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES=true
```
</TabItem>
</Tabs>
:::note
This flag only applies to the `openai` provider. Azure OpenAI and other providers are unaffected.
:::
## Free-form Function Calling
<Tabs>

View file

@ -218,8 +218,8 @@ modify_params = bool(os.getenv("LITELLM_MODIFY_PARAMS", False))
use_chat_completions_url_for_anthropic_messages: bool = bool(
os.getenv("LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES", False)
) # When True, routes OpenAI /v1/messages requests to chat/completions instead of the Responses API
route_all_chat_openai_to_responses: bool = bool(
os.getenv("LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES", False)
route_all_chat_openai_to_responses: bool = (
os.getenv("LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES", "false").lower() == "true"
) # When True, routes all OpenAI /chat/completions requests through the Responses API bridge
retry = True
### AUTH ###

View file

@ -940,7 +940,8 @@ def responses_api_bridge_check(
) -> Tuple[dict, str]:
model_info: Dict[str, Any] = {}
# Global flag: route ALL OpenAI chat completions through Responses API
# Global flag: route ALL OpenAI chat completions through Responses API.
# Returns early with minimal model_info; callers only inspect the "mode" key.
if litellm.route_all_chat_openai_to_responses and custom_llm_provider == "openai":
model = model.replace("responses/", "")
model_info["mode"] = "responses"