The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(openai): fix env var bool parsing and add responses API docs
Sameer Kankute6072d1b66ee1
diff --git a/docs/my-website/docs/providers/openai/responses_api.md b/docs/my-website/docs/providers/openai/responses_api.mdindex 0d6b9013ac8..31f21ba52a7 100644--- a/docs/my-website/docs/providers/openai/responses_api.md+++ b/docs/my-website/docs/providers/openai/responses_api.md@@ -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>diff --git a/litellm/__init__.py b/litellm/__init__.pyindex e12e4ef6ee8..7e81f624b3c 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -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 bridgeretry = True### AUTH ###diff --git a/litellm/main.py b/litellm/main.pyindex 619c2f37c24..b5636ab1c88 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -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"