mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-29 01:03:17 +00:00
* fix(responses): reject an unresolvable previous_response_id on the chat completions bridge A follow-up whose earlier turns cannot be found in the spend logs now answers 400 previous_response_not_found, matching OpenAI, before any provider call, so it is never answered without context or billed. The sync litellm.responses() bridge path now rebuilds history the same way as the async path. * fix(responses): keep param on the input token count's previous_response_id 400 The input token count route rebuilt the bridge error with param null, so a client could not tell the count was refused on previous_response_id. The chat count error now carries the exception's param through to the proxy response * fix(responses): give SDK installs the previous_response_id 400 and type WebSocket turn errors by status An SDK install without the proxy extras now gets the same 400 instead of a 500, the hint names the proxy's spend logs, and managed WebSocket turn failures carry the per-status error type plus OpenAI's code and param * fix(responses): refuse a sync follow-up that would query the proxy's database off its event loop * fix(responses): refuse sync follow-ups without querying the proxy database and keep sync compaction working * fix(ui): resend the whole conversation when the proxy cannot resolve previous_response_id The chat page and the Playground send only the new message with previous_response_id. When the proxy answers 400 on that id, they now retry once with the full conversation and continue the session from the new response. The 400 message also says the prompt storage setting must not be turned off in the key's or team's metadata * fix(ui): keep sending the whole conversation after the proxy could not resolve previous_response_id After one resend without previous_response_id, later turns send the full history until the chat, session toggle, model or conversation resets, so a lost session never answers the follow-up without context * fix(responses): count an unresolvable previous_response_id as the caller's error and keep its code in background polls * fix(ui): declare the Playground chat hook's model change reset in its return type * test(responses): drop the fixed wait from the router failure-count test The router counts failures inline before the refused call returns, so the test checks the deployment's state right after the calls * fix(responses): never retry or fall back on an unresolvable previous_response_id, and let input that carries its history through The router now ends retries and skips fallbacks for the 400, so a retry policy or a fallback group no longer runs it again or forwards the unknown id The 400 is a client error, so it sends no Slack llm_exceptions alert A follow-up whose input already holds an earlier assistant reply or tool call goes through without the stored turns, and input holding only a tool output still gets the 400 A background follow-up that gets the 400 polls failed with previous_response_not_found, and every other background failure keeps its old error * fix(ui): start a new trace when the Playground model changes A model change already starts a new Responses session, but the old trace id stayed. The first turn after the change resends the whole conversation under that trace id, so with store_prompts_in_spend_logs on, the next bridged follow-up was rebuilt from both the old chain and the resent history and the provider got the earlier turns twice * fix(router): end the fallback chain when a fallback refuses a follow-up A fallback hop that cannot find a follow-up's earlier turns now ends the call with its 400 instead of sending the same id to the next fallback, and the SDK's num_retries no longer reruns that 400 * fix(router): answer with the fallback's 400 when it cannot find the previous response When the first group fails for another reason and a fallback refuses a follow-up because its previous_response_id is unknown, the caller now gets that 400 with param previous_response_id instead of the first group's error, so a client can resend the whole conversation The walk still ends at the refusing fallback and never calls the next one * fix(router): let the next fallback answer a follow-up to a response a provider holds * fix(router): treat previous_response_id 400s as the caller's error and keep the usual all-fail error A provider 400 naming previous_response_id no longer counts against the deployment or cools it down. A follow-up to a turn a native Responses deployment holds keeps its fallbacks with fallback_on_unsupported_params off, and when every fallback fails the caller gets the router's usual error A follow-up to a turn the chat bridge answered ends the walk for every provider, Gemini included * fix(router): don't cool down a fallback deployment on a previous_response_id 400 A provider's 400 naming previous_response_id at a fallback hop went through the fallback cooldown path, which lacked the exit the first logged failure already had, so a store: false turn's follow-ups cooled the native fallback down * fix(responses): let a native turn on a provider without resp_ ids reach the next fallback A native Responses turn counted as provider-held only when its original id started with resp_, so an xAI turn, whose ids are UUIDs, ended the fallback walk at the first bridged group with the 400 even though a native xAI fallback could answer it. A turn now counts as provider-held when its provider has a native Responses config and its id is not a chat completion id * fix(responses): answer a non-string previous_response_id on the chat bridge with a 400 A previous_response_id that is not a string, such as 123 or a list, reached the bridge's check for whether a provider holds the turn and crashed there, so the caller got a 500 or a 400 carrying a traceback. The bridge now refuses it with an invalid_request_error naming previous_response_id before it looks the turn up or calls the provider * fix(responses): stop retrying and falling back on a non-string previous_response_id The chat bridge's 400 for a previous_response_id that is not a string was a plain BadRequestError. A BadRequestErrorRetries policy and the SDK's num_retries retried it, a fallback group got the same bad id, and the Slack llm_exceptions alert fired. It now raises the same error class as a follow-up to a turn no provider holds, so retries and fallbacks end and the router and proxy treat it as the caller's error * test(proxy): read the lost previous_response_id from a spend log double --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
1515 lines
61 KiB
Python
1515 lines
61 KiB
Python
"""
|
|
Tests for forcing the /responses → /chat/completions bridge for `openai/` models
|
|
(via `use_chat_completions_api` or the `openai/chat_completions/<model>` model id).
|
|
|
|
Includes file_search emulation: the flag must be forwarded on inner aresponses
|
|
calls so routed requests do not hit a custom api_base /v1/responses endpoint.
|
|
"""
|
|
|
|
import copy
|
|
import json
|
|
from collections.abc import Mapping
|
|
from importlib import import_module
|
|
from pathlib import Path
|
|
from typing import Final, cast
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import httpx
|
|
import openai
|
|
import pytest
|
|
import respx
|
|
from pydantic import JsonValue
|
|
|
|
import litellm
|
|
from litellm import Router
|
|
from litellm.llms.custom_httpx.http_handler import HTTPHandler
|
|
from litellm.responses.bridge_check import (
|
|
backend_serves_chat_completions,
|
|
bridge_reasoning_effort,
|
|
deployment_routing_mode,
|
|
responses_api_bridge_check,
|
|
)
|
|
from litellm.types.llms.openai import ResponseAPIUsage, ResponsesAPIResponse
|
|
from litellm.types.utils import Choices, Message, ModelResponse, Usage
|
|
|
|
|
|
class TestUseResponsesApiBridgeFlag:
|
|
"""Test that bridge opt-in forces the chat completions path."""
|
|
|
|
@pytest.mark.parametrize("model", ["openai/chat_completions/gpt-6-astra", "xai/test-classifier"])
|
|
def test_encrypted_classifier_rejection_preserves_public_error(self, model: str) -> None:
|
|
respond: Final = MagicMock(side_effect=AssertionError("Incompatible classifier sent an upstream request"))
|
|
with httpx.Client(transport=httpx.MockTransport(respond)) as client:
|
|
with pytest.raises(
|
|
litellm.APIConnectionError,
|
|
match="Encrypted task classification requires a compatible native Responses deployment",
|
|
) as error:
|
|
litellm.responses(
|
|
model=model,
|
|
input="Delegated task",
|
|
api_key="test-key",
|
|
api_base="https://classifier.test/v1",
|
|
client=HTTPHandler(client=client),
|
|
_require_encrypted_task_support=True,
|
|
num_retries=0,
|
|
)
|
|
assert error.value.status_code == 500
|
|
respond.assert_not_called()
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_bridge_used_when_use_chat_completions_api_true(self, mock_get_config, mock_bridge_handler):
|
|
"""When use_chat_completions_api=True, the bridge handler should be called."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_bridge_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="openai/my-custom-model",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_bridge_handler.assert_called_once()
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_provider_affinity_header_is_forwarded_through_bridge(self, mock_get_config, mock_bridge_handler):
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_bridge_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="openai/my-custom-model",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
litellm_session_id="session-bridge",
|
|
provider_affinity_header="X-Conversation-Id",
|
|
extra_headers={"X-Customer-Header": "customer-value"},
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
forwarded_headers = mock_bridge_handler.call_args.kwargs["extra_headers"]
|
|
assert forwarded_headers["X-Conversation-Id"] == "session-bridge"
|
|
assert forwarded_headers["X-Customer-Header"] == "customer-value"
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_bridge_used_when_model_uses_chat_completions_prefix(self, mock_get_config, mock_bridge_handler):
|
|
"""`openai/chat_completions/<name>` normalizes to `openai/<name>` and uses the bridge."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_bridge_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="openai/chat_completions/my-custom-model",
|
|
input="Hello",
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_bridge_handler.assert_called_once()
|
|
# Model string is provider-normalized after resolution; prefix only forces the bridge.
|
|
assert mock_bridge_handler.call_args.kwargs["model"].endswith("my-custom-model")
|
|
|
|
@patch.object(import_module("litellm.responses.main").base_llm_http_handler, "response_api_handler")
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_native_forwarding_when_flag_absent(self, mock_get_config, mock_native_handler):
|
|
"""When use_chat_completions_api is not set, openai/ models should use
|
|
native responses API forwarding (existing behavior)."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_native_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="openai/gpt-4o",
|
|
input="Hello",
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_native_handler.assert_called_once()
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_flag_does_not_leak_into_kwargs(self, mock_get_config, mock_bridge_handler):
|
|
"""use_chat_completions_api should be popped and not passed to the bridge handler."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_bridge_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="openai/my-custom-model",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
call_kwargs = mock_bridge_handler.call_args
|
|
all_kwargs = call_kwargs.kwargs if call_kwargs.kwargs else {}
|
|
assert "use_chat_completions_api" not in all_kwargs
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
def test_bridge_used_when_provider_config_none(self, mock_get_config, mock_bridge_handler):
|
|
"""When the provider has no native responses API config (returns None),
|
|
the bridge should be used regardless of the flag (existing behavior)."""
|
|
mock_get_config.return_value = None
|
|
mock_bridge_handler.return_value = MagicMock()
|
|
|
|
litellm.responses(
|
|
model="anthropic/claude-3-haiku",
|
|
input="Hello",
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_bridge_handler.assert_called_once()
|
|
|
|
@patch("litellm.acompletion")
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
async def test_allowed_openai_params_forwarded_through_bridge(self, mock_get_config, mock_acompletion):
|
|
"""allowed_openai_params is a named param of responses(), so it must be
|
|
explicitly forwarded to the bridge; otherwise litellm.acompletion raises
|
|
UnsupportedParamsError for params the caller explicitly allowed."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_acompletion.return_value = ModelResponse(
|
|
id="chatcmpl_123",
|
|
model="openai/my-custom-model",
|
|
choices=[
|
|
Choices(
|
|
index=0,
|
|
message=Message(role="assistant", content="Answer"),
|
|
finish_reason="stop",
|
|
)
|
|
],
|
|
usage=Usage(prompt_tokens=10, completion_tokens=5, total_tokens=15),
|
|
)
|
|
|
|
await litellm.aresponses(
|
|
model="openai/my-custom-model",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
allowed_openai_params=["reasoning_effort"],
|
|
reasoning={"effort": "high"},
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_acompletion.assert_called_once()
|
|
assert mock_acompletion.call_args.kwargs.get("allowed_openai_params") == ["reasoning_effort"]
|
|
|
|
@pytest.mark.parametrize(
|
|
("model", "upstream_url", "use_chat_completions_api", "allowed_openai_params", "expected_chat_template_kwargs"),
|
|
[
|
|
pytest.param(
|
|
"openai/my-custom-model",
|
|
"https://api.openai.com/v1/chat/completions",
|
|
True,
|
|
None,
|
|
None,
|
|
id="native-config-drops-unknown-param",
|
|
),
|
|
pytest.param(
|
|
"openai/my-custom-model",
|
|
"https://api.openai.com/v1/chat/completions",
|
|
True,
|
|
["chat_template_kwargs"],
|
|
{"thinking": True},
|
|
id="native-config-keeps-allowed-param",
|
|
),
|
|
pytest.param(
|
|
"together_ai/my-custom-model",
|
|
"https://api.together.ai/v1/chat/completions",
|
|
False,
|
|
None,
|
|
{"thinking": True},
|
|
id="no-native-config-keeps-passthrough",
|
|
),
|
|
],
|
|
)
|
|
def test_bridge_forwards_same_params_as_native_dispatch(
|
|
self,
|
|
model: str,
|
|
upstream_url: str,
|
|
use_chat_completions_api: bool,
|
|
allowed_openai_params: list[str] | None,
|
|
expected_chat_template_kwargs: dict[str, bool] | None,
|
|
respx_mock: respx.MockRouter,
|
|
):
|
|
upstream: Final = respx_mock.post(upstream_url).mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
response: Final = litellm.responses(
|
|
model=model,
|
|
input="Hello",
|
|
use_chat_completions_api=use_chat_completions_api,
|
|
allowed_openai_params=allowed_openai_params,
|
|
chat_template_kwargs={"thinking": True},
|
|
drop_params=True,
|
|
api_key="fake-provider-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
request_body: Final = json.loads(upstream.calls[0].request.read())
|
|
assert request_body.get("chat_template_kwargs") == expected_chat_template_kwargs
|
|
assert request_body["messages"] == [{"role": "user", "content": "Hello"}]
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_drops_client_metadata_even_when_allowed_openai_params_names_it(self, respx_mock: respx.MockRouter):
|
|
upstream: Final = respx_mock.post("https://api.openai.com/v1/chat/completions").mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
response: Final = litellm.responses(
|
|
model="openai/my-custom-model",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
allowed_openai_params=["client_metadata"],
|
|
client_metadata={"turn_id": "turn-1", "thread_id": "thread-1"},
|
|
api_key="fake-provider-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
request_body: Final = json.loads(upstream.calls[0].request.read())
|
|
assert "client_metadata" not in request_body
|
|
assert request_body["messages"] == [{"role": "user", "content": "Hello"}]
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_sends_a_responses_layout_allowed_tools_tool_choice_in_the_chat_layout(
|
|
self, respx_mock: respx.MockRouter
|
|
):
|
|
upstream: Final = respx_mock.post("https://api.openai.com/v1/chat/completions").mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
litellm.responses(
|
|
model="openai/my-custom-model",
|
|
input="What time is it?",
|
|
use_chat_completions_api=True,
|
|
tools=[
|
|
{"type": "function", "name": name, "parameters": {"type": "object", "properties": {}}}
|
|
for name in ("get_time", "get_weather")
|
|
],
|
|
tool_choice={"type": "allowed_tools", "mode": "required", "tools": [{"type": "function", "name": "get_time"}]},
|
|
api_key="fake-provider-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read())["tool_choice"] == {
|
|
"type": "allowed_tools",
|
|
"allowed_tools": {"mode": "required", "tools": [{"type": "function", "function": {"name": "get_time"}}]},
|
|
}
|
|
|
|
def test_bridge_merges_instructions_and_developer_input_for_databricks(self, respx_mock: respx.MockRouter):
|
|
upstream: Final = respx_mock.post("https://example.databricks.test/serving-endpoints/chat/completions").mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
response: Final = litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
instructions="You are terse.",
|
|
input=[
|
|
{"role": "developer", "content": [{"type": "input_text", "text": "Skills: none."}]},
|
|
{"role": "user", "content": [{"type": "input_text", "text": "Hello"}]},
|
|
],
|
|
client_metadata={"turn_id": "turn-1", "thread_id": "thread-1"},
|
|
chat_template_kwargs={"thinking": True},
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
request_body: Final = json.loads(upstream.calls[0].request.read())
|
|
assert request_body["messages"] == [
|
|
{"role": "system", "content": "You are terse.\n\nSkills: none."},
|
|
{"role": "user", "content": "Hello"},
|
|
]
|
|
assert "client_metadata" not in request_body
|
|
assert request_body["chat_template_kwargs"] == {"thinking": True}
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_drops_client_metadata_for_provider_without_native_config(self, respx_mock: respx.MockRouter):
|
|
upstream: Final = respx_mock.post("https://example.databricks.test/serving-endpoints/chat/completions").mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
response: Final = litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
client_metadata={
|
|
"turn_id": "turn-1",
|
|
"thread_id": "thread-1",
|
|
"session_id": "session-1",
|
|
"root_turn_id": "turn-1",
|
|
"x-codex-installation-id": "install-1",
|
|
"x-codex-turn-metadata": '{"turn_id":"turn-1"}',
|
|
},
|
|
chat_template_kwargs={"thinking": True},
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
request_body: Final = json.loads(upstream.calls[0].request.read())
|
|
assert "client_metadata" not in request_body
|
|
assert request_body["chat_template_kwargs"] == {"thinking": True}
|
|
assert request_body["messages"] == [{"role": "user", "content": "Hello"}]
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_keeps_deployment_credentials_while_dropping_unknown_params(self, respx_mock: respx.MockRouter):
|
|
upstream: Final = respx_mock.post(
|
|
"https://example-resource.openai.azure.com/openai/deployments/my-deployment/chat/completions",
|
|
params={"api-version": "2024-10-21"},
|
|
).mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-deployment",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
litellm.responses(
|
|
model="azure/my-deployment",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
api_base="https://example-resource.openai.azure.com",
|
|
api_version="2024-10-21",
|
|
azure_ad_token="fake-azure-ad-token",
|
|
chat_template_kwargs={"thinking": True},
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
request: Final = upstream.calls[0].request
|
|
assert request.headers["authorization"] == "Bearer fake-azure-ad-token"
|
|
assert "chat_template_kwargs" not in json.loads(request.read())
|
|
|
|
def test_bridge_rejects_a_responses_field_it_cannot_translate_when_drop_params_is_off(
|
|
self, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
with pytest.raises(litellm.UnsupportedParamsError) as raised:
|
|
litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
max_tool_calls=5,
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 0, "the provider must not be called for a field the bridge cannot translate"
|
|
assert raised.value.status_code == 400
|
|
assert "max_tool_calls" in str(raised.value)
|
|
assert "drop_params" in str(raised.value)
|
|
|
|
@pytest.mark.parametrize("drop_params_source", ["request", "global"])
|
|
def test_bridge_drops_a_responses_field_it_cannot_translate_when_drop_params_is_on(
|
|
self, drop_params_source: str, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", drop_params_source == "global")
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
response: Final = litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
max_tool_calls=5,
|
|
chat_template_kwargs={"thinking": True},
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
**({"drop_params": True} if drop_params_source == "request" else {}),
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "my-custom-model",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
"chat_template_kwargs": {"thinking": True},
|
|
}
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_drops_a_responses_field_it_cannot_translate_when_the_deployment_sets_drop_params(
|
|
self, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
router: Final = Router(
|
|
model_list=[
|
|
{
|
|
"model_name": "bridged",
|
|
"litellm_params": {
|
|
"model": "databricks/my-custom-model",
|
|
"api_base": "https://example.databricks.test/serving-endpoints",
|
|
"api_key": "fake-databricks-api-key",
|
|
"drop_params": True,
|
|
},
|
|
}
|
|
],
|
|
num_retries=0,
|
|
)
|
|
|
|
response: Final = router.responses(model="bridged", input="Hello", max_tool_calls=5)
|
|
|
|
assert upstream.call_count == 1
|
|
request_body: Final = json.loads(upstream.calls[0].request.read())
|
|
assert "max_tool_calls" not in request_body
|
|
assert request_body["messages"] == [{"role": "user", "content": "Hello"}]
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_allowed_openai_params_sends_a_responses_field_through_the_bridge(
|
|
self, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
max_tool_calls=5,
|
|
allowed_openai_params=["max_tool_calls"],
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read())["max_tool_calls"] == 5
|
|
|
|
def test_bridge_still_honors_additional_drop_params_for_a_responses_field_it_cannot_translate(
|
|
self, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
response: Final = litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
max_tool_calls=5,
|
|
additional_drop_params=["max_tool_calls"],
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "my-custom-model",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
}
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
def test_bridge_still_quietly_drops_responses_fields_it_already_handles(
|
|
self, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
):
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
store=False,
|
|
include=["reasoning.encrypted_content"],
|
|
truncation="auto",
|
|
metadata={"k": "v"},
|
|
background=False,
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "my-custom-model",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
}
|
|
|
|
@patch.object(import_module("litellm.responses.file_search.emulated_handler"), "_call_aresponses")
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
async def test_bridge_flag_forwarded_to_file_search_emulation(self, mock_get_config, mock_call_aresponses):
|
|
"""When use_chat_completions_api=True and file_search tool is present,
|
|
the flag should be forwarded to the inner aresponses call in the
|
|
file_search emulation path."""
|
|
# Setup: provider has native responses API support
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
|
|
# Mock the inner aresponses call to return a valid response
|
|
mock_response = ResponsesAPIResponse(
|
|
id="resp_123",
|
|
model="openai/my-custom-model",
|
|
created_at=1234567890,
|
|
output=[{"type": "message", "content": [{"type": "text", "text": "Answer"}]}],
|
|
usage=ResponseAPIUsage(input_tokens=10, output_tokens=5, total_tokens=15),
|
|
)
|
|
mock_call_aresponses.return_value = mock_response
|
|
|
|
await litellm.aresponses(
|
|
model="openai/my-custom-model",
|
|
input="Search for information",
|
|
tools=[{"type": "file_search"}],
|
|
use_chat_completions_api=True,
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
# Verify _call_aresponses was called with use_chat_completions_api=True
|
|
mock_call_aresponses.assert_called_once()
|
|
call_kwargs = mock_call_aresponses.call_args.kwargs
|
|
assert call_kwargs.get("use_chat_completions_api") is True, (
|
|
"use_chat_completions_api should be forwarded to inner aresponses call"
|
|
)
|
|
|
|
@patch.object(
|
|
import_module("litellm.responses.main").litellm_completion_transformation_handler, "response_api_handler"
|
|
)
|
|
@patch("litellm.vector_stores.main.asearch")
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
async def test_bridge_flag_prevents_native_responses_endpoint_call(
|
|
self, mock_get_config, mock_asearch, mock_bridge_handler
|
|
):
|
|
"""
|
|
Concrete failing scenario: native OpenAI responses config + bridge flag +
|
|
file_search → emulation must still route inner calls through the bridge
|
|
(chat completions), not POST to api_base /v1/responses.
|
|
"""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_asearch.return_value = []
|
|
|
|
first_response = ResponsesAPIResponse(
|
|
id="resp_first",
|
|
model="openai/my-local-model",
|
|
created_at=1234567890,
|
|
output=[
|
|
{
|
|
"type": "function_call",
|
|
"name": "litellm_file_search",
|
|
"call_id": "call_123",
|
|
"arguments": '{"queries": ["test query"]}',
|
|
}
|
|
],
|
|
usage=ResponseAPIUsage(input_tokens=10, output_tokens=5, total_tokens=15),
|
|
)
|
|
second_response = ResponsesAPIResponse(
|
|
id="resp_second",
|
|
model="openai/my-local-model",
|
|
created_at=1234567891,
|
|
output=[
|
|
{
|
|
"type": "message",
|
|
"content": [{"type": "text", "text": "Final answer"}],
|
|
}
|
|
],
|
|
usage=ResponseAPIUsage(input_tokens=20, output_tokens=10, total_tokens=30),
|
|
)
|
|
mock_bridge_handler.side_effect = [first_response, second_response]
|
|
|
|
result = await litellm.aresponses(
|
|
model="openai/my-local-model",
|
|
input="Search for information",
|
|
tools=[
|
|
{
|
|
"type": "file_search",
|
|
"file_search": {"vector_store_ids": ["vs_123"]},
|
|
}
|
|
],
|
|
use_chat_completions_api=True,
|
|
api_base="http://localhost:8080/v1",
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
assert mock_bridge_handler.call_count == 2, (
|
|
"Bridge handler should be called twice: initial function-tool call and follow-up with tool results"
|
|
)
|
|
for call in mock_bridge_handler.call_args_list:
|
|
all_kwargs = call.kwargs if call.kwargs else {}
|
|
assert "use_chat_completions_api" not in all_kwargs
|
|
assert result is not None
|
|
assert result.id is not None
|
|
|
|
@patch.object(import_module("litellm.responses.main").base_llm_http_handler, "response_api_handler")
|
|
@patch("litellm.vector_stores.main.asearch")
|
|
@patch.object(import_module("litellm.responses.main").ProviderConfigManager, "get_provider_responses_api_config")
|
|
async def test_without_bridge_flag_uses_native_endpoint(self, mock_get_config, mock_asearch, mock_native_handler):
|
|
"""Without the bridge flag, openai/ with native config uses the native handler."""
|
|
mock_get_config.return_value = litellm.OpenAIResponsesAPIConfig()
|
|
mock_asearch.return_value = []
|
|
mock_native_handler.return_value = ResponsesAPIResponse(
|
|
id="resp_native",
|
|
model="openai/gpt-4o",
|
|
created_at=1234567890,
|
|
output=[
|
|
{
|
|
"type": "message",
|
|
"content": [{"type": "text", "text": "Native response"}],
|
|
}
|
|
],
|
|
usage=ResponseAPIUsage(input_tokens=10, output_tokens=5, total_tokens=15),
|
|
)
|
|
|
|
result = await litellm.aresponses(
|
|
model="openai/gpt-4o",
|
|
input="Hello",
|
|
litellm_logging_obj=MagicMock(),
|
|
)
|
|
|
|
mock_native_handler.assert_called_once()
|
|
assert result is not None
|
|
|
|
def test_bridge_still_rejects_an_invalid_stream_chunk_size(self) -> None:
|
|
send: Final = MagicMock(return_value=httpx.Response(200))
|
|
client: Final = openai.OpenAI(api_key="fake-key", http_client=httpx.Client(transport=httpx.MockTransport(send)))
|
|
|
|
with pytest.raises(litellm.BadRequestError) as exc_info:
|
|
litellm.responses(
|
|
model="openai/gpt-4.1-mini",
|
|
input="hi",
|
|
use_chat_completions_api=True,
|
|
stream_chunk_size="sixty-four",
|
|
client=client,
|
|
num_retries=0,
|
|
)
|
|
|
|
assert exc_info.value.param == "stream_chunk_size"
|
|
send.assert_not_called()
|
|
|
|
|
|
# Deployment-pinned routing mode (deployment_routing_mode / responses_api_bridge_check)
|
|
_CHAT: Final[Mapping[str, JsonValue]] = {"id": "dep-1", "mode": "chat"}
|
|
_RESPONSES: Final[Mapping[str, JsonValue]] = {"id": "dep-1", "mode": "responses"}
|
|
|
|
|
|
def _databricks_chat_upstream(respx_mock: respx.MockRouter) -> respx.Route:
|
|
return respx_mock.post("https://example.databricks.test/serving-endpoints/chat/completions").mock(
|
|
return_value=httpx.Response(
|
|
status_code=200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "my-custom-model",
|
|
"choices": [
|
|
{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}
|
|
],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
)
|
|
|
|
|
|
def _pin_shared_mode(monkeypatch: pytest.MonkeyPatch, model: str, mode: str) -> None:
|
|
cost_map: Final = cast(dict[str, dict[str, object]], litellm.model_cost)
|
|
monkeypatch.setitem(cost_map, model, {**cost_map.get(model, {}), "mode": mode})
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"deployment_model_info, custom_llm_provider, expected",
|
|
[
|
|
(_CHAT, "bedrock_mantle", "chat"),
|
|
(_RESPONSES, "bedrock_mantle", "responses"),
|
|
(_CHAT, "openai", "chat"),
|
|
(_CHAT, "chatgpt", None),
|
|
(_CHAT, "github_copilot", None),
|
|
({"id": "dep-1", "mode": "embedding"}, "bedrock_mantle", None),
|
|
({"id": "dep-1"}, "bedrock_mantle", None),
|
|
(None, "bedrock_mantle", None),
|
|
],
|
|
)
|
|
def test_deployment_routing_mode_pins_chat_or_responses_except_on_responses_only_backends(
|
|
deployment_model_info: Mapping[str, JsonValue] | None, custom_llm_provider: str, expected: str | None
|
|
) -> None:
|
|
assert deployment_routing_mode(deployment_model_info, custom_llm_provider) == expected
|
|
|
|
|
|
def test_a_chat_pinned_mantle_deployment_stays_on_chat_completions_while_the_shared_row_says_responses(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
model: Final = "bedrock_mantle/openai.gpt-5.6-sol"
|
|
_pin_shared_mode(monkeypatch, model, "responses")
|
|
shared_info, _ = responses_api_bridge_check(model=model, custom_llm_provider="bedrock_mantle")
|
|
pinned_info, pinned_model = responses_api_bridge_check(
|
|
model=model, custom_llm_provider="bedrock_mantle", deployment_model_info=_CHAT
|
|
)
|
|
assert shared_info["mode"] == "responses"
|
|
assert (pinned_info["mode"], pinned_model) == ("chat", model)
|
|
|
|
|
|
def test_a_chat_pinned_chatgpt_alias_still_bridges_to_the_responses_api(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
_pin_shared_mode(monkeypatch, "chatgpt/gpt-5.4", "responses")
|
|
info, _ = responses_api_bridge_check(model="gpt-5.4", custom_llm_provider="chatgpt", deployment_model_info=_CHAT)
|
|
assert info["mode"] == "responses"
|
|
|
|
|
|
_FUNCTION_TOOL: Final[dict[str, JsonValue]] = {
|
|
"type": "function",
|
|
"function": {"name": "lookup", "parameters": {"type": "object", "properties": {}}},
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize("custom_llm_provider", ["openai", "azure"])
|
|
@pytest.mark.parametrize(("effort", "mode"), ((None, "chat"), ("medium", "responses")))
|
|
def test_a_chat_pin_routes_gpt_5_4_function_tools_by_explicit_effort(
|
|
custom_llm_provider: str, effort: str | None, mode: str
|
|
) -> None:
|
|
info, model = responses_api_bridge_check(
|
|
model="gpt-5.4",
|
|
custom_llm_provider=custom_llm_provider,
|
|
tools=[_FUNCTION_TOOL],
|
|
reasoning_effort=effort,
|
|
api_base="https://example.openai.azure.com" if custom_llm_provider == "azure" else None,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], model) == (mode, "gpt-5.4")
|
|
|
|
|
|
@pytest.mark.parametrize("provider", ("openai", "azure"))
|
|
@pytest.mark.parametrize(
|
|
("model", "effort", "extra_body", "expected"),
|
|
(
|
|
("gpt-5.4-mini", None, None, "chat"),
|
|
("gpt-5.4-nano", None, None, "chat"),
|
|
("gpt-5.5", None, None, "chat"),
|
|
("gpt-5.6", None, None, "responses"),
|
|
("gpt-6.1-sol", None, None, "responses"),
|
|
("gpt-5.4-mini", "none", None, "chat"),
|
|
("gpt-5.4-mini", "medium", None, "responses"),
|
|
("gpt-5.4-mini", {"effort": "medium"}, None, "responses"),
|
|
("gpt-5.4-mini", None, {"reasoning_effort": "medium"}, "responses"),
|
|
),
|
|
)
|
|
def test_function_tools_bridge_only_when_chat_rejects_the_effective_effort(
|
|
provider: str,
|
|
model: str,
|
|
effort: str | Mapping[str, object] | None,
|
|
extra_body: Mapping[str, object] | None,
|
|
expected: str,
|
|
) -> None:
|
|
info, _ = responses_api_bridge_check(
|
|
model=model,
|
|
custom_llm_provider=provider,
|
|
tools=[_FUNCTION_TOOL],
|
|
reasoning_effort=bridge_reasoning_effort(
|
|
effort, extra_body, custom_llm_provider=provider, api_base="https://api.openai.com/v1"
|
|
),
|
|
api_base="https://api.openai.com/v1",
|
|
)
|
|
assert info.get("mode") == expected
|
|
|
|
|
|
@pytest.mark.parametrize("region", ("us", "eu"))
|
|
@pytest.mark.parametrize("model", ("gpt-5.4-mini", "gpt-5.4-nano"))
|
|
def test_regional_azure_default_none_function_tools_stay_on_chat(region: str, model: str) -> None:
|
|
info, _ = responses_api_bridge_check(
|
|
model=f"{region}/{model}", custom_llm_provider="azure", tools=[_FUNCTION_TOOL]
|
|
)
|
|
assert info.get("mode") == "chat"
|
|
assert info.get("default_reasoning_effort") == litellm.model_cost[f"azure/{model}"]["default_reasoning_effort"]
|
|
|
|
|
|
def test_registered_gpt_5_6_default_none_function_tools_stay_on_chat(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
model: Final = "gpt-5.6-test-default-none"
|
|
monkeypatch.setitem(
|
|
litellm.model_cost,
|
|
model,
|
|
{**litellm.model_cost["gpt-5.6"], "default_reasoning_effort": "none"},
|
|
)
|
|
info, _ = responses_api_bridge_check(
|
|
model=model, custom_llm_provider="openai", tools=[_FUNCTION_TOOL], api_base="https://api.openai.com/v1"
|
|
)
|
|
assert info.get("mode") == "chat"
|
|
|
|
|
|
@pytest.mark.parametrize("model", ["openai.gpt-5.6-terra", "us-east-1/openai.gpt-5.6-terra"])
|
|
@pytest.mark.parametrize("reasoning_effort", [None, "low"])
|
|
def test_a_chat_pinned_mantle_deployment_sends_function_tools_to_the_responses_api(
|
|
model: str, reasoning_effort: str | None
|
|
) -> None:
|
|
"""Mantle Chat Completions rejects function tools on gpt-5.4+ unless reasoning is off, so a ``mode: chat``
|
|
pin cannot keep a tool call there."""
|
|
info, routed_model = responses_api_bridge_check(
|
|
model=model,
|
|
custom_llm_provider="bedrock_mantle",
|
|
tools=[_FUNCTION_TOOL],
|
|
reasoning_effort=reasoning_effort,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], routed_model) == ("responses", model)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"reasoning_effort, reasoning_summary",
|
|
[("low", "auto"), ({"effort": "low", "summary": "auto"}, None)],
|
|
)
|
|
def test_a_chat_pinned_mantle_deployment_sends_a_reasoning_summary_to_the_responses_api(
|
|
reasoning_effort: str | Mapping[str, JsonValue], reasoning_summary: str | None
|
|
) -> None:
|
|
info, _ = responses_api_bridge_check(
|
|
model="openai.gpt-5.6-terra",
|
|
custom_llm_provider="bedrock_mantle",
|
|
reasoning_effort=reasoning_effort,
|
|
reasoning_summary=reasoning_summary,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert info["mode"] == "responses"
|
|
|
|
|
|
def test_a_chat_pinned_mantle_deployment_sends_web_search_to_the_responses_api() -> None:
|
|
info, model = responses_api_bridge_check(
|
|
model="openai.gpt-5.6-terra",
|
|
custom_llm_provider="bedrock_mantle",
|
|
web_search_options={"search_context_size": "medium"},
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], model) == ("responses", "openai.gpt-5.6-terra")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"model, reasoning_effort",
|
|
[
|
|
("openai.gpt-5.6-terra", "none"),
|
|
("openai.gpt-oss-120b", "low"),
|
|
("openai.gpt-oss-safeguard-120b", "low"),
|
|
],
|
|
)
|
|
def test_a_chat_pinned_mantle_tool_call_stays_on_chat_completions_when_chat_accepts_it(
|
|
model: str, reasoning_effort: str
|
|
) -> None:
|
|
info, routed_model = responses_api_bridge_check(
|
|
model=model,
|
|
custom_llm_provider="bedrock_mantle",
|
|
tools=[_FUNCTION_TOOL],
|
|
reasoning_effort=reasoning_effort,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], routed_model) == ("chat", model)
|
|
|
|
|
|
def test_a_chat_pin_cannot_pull_xai_web_search_off_the_responses_api() -> None:
|
|
info, model = responses_api_bridge_check(
|
|
model="grok-4",
|
|
custom_llm_provider="xai",
|
|
web_search_options={"search_context_size": "medium"},
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], model) == ("responses", "grok-4")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"model, custom_llm_provider, api_base",
|
|
[
|
|
("responses/my-azure-deployment", "azure", "https://example.openai.azure.com"),
|
|
("responses/gpt-5.4", "openai", None),
|
|
],
|
|
)
|
|
def test_a_chat_pin_does_not_override_an_explicit_responses_prefix(
|
|
model: str, custom_llm_provider: str, api_base: str | None
|
|
) -> None:
|
|
info, sent_model = responses_api_bridge_check(
|
|
model=model,
|
|
custom_llm_provider=custom_llm_provider,
|
|
api_base=api_base,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], sent_model) == ("responses", model.removeprefix("responses/"))
|
|
|
|
|
|
def test_a_chat_pinned_responses_prefixed_router_deployment_reaches_the_responses_api(
|
|
monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
) -> None:
|
|
"""The router registers a ``mode: chat`` row under the deployment's own ``responses/gpt-5.6`` name,
|
|
so the prefix has to win over that row too, or the request goes to Chat Completions as ``responses/gpt-5.6``."""
|
|
monkeypatch.setattr(litellm, "model_cost", copy.deepcopy(litellm.model_cost))
|
|
responses_route: Final = respx_mock.post("https://api.openai.com/v1/responses").mock(
|
|
return_value=httpx.Response(
|
|
200,
|
|
json={
|
|
"id": "resp_1",
|
|
"object": "response",
|
|
"created_at": 1,
|
|
"status": "completed",
|
|
"model": "gpt-5.6",
|
|
"output": [
|
|
{
|
|
"type": "message",
|
|
"id": "msg_1",
|
|
"status": "completed",
|
|
"role": "assistant",
|
|
"content": [{"type": "output_text", "text": "ok", "annotations": []}],
|
|
}
|
|
],
|
|
"usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2},
|
|
},
|
|
)
|
|
)
|
|
router: Final = Router(
|
|
model_list=[
|
|
{
|
|
"model_name": "prefixed-chat",
|
|
"litellm_params": {
|
|
"model": "openai/responses/gpt-5.6",
|
|
"custom_llm_provider": "openai",
|
|
"api_key": "sk-test",
|
|
},
|
|
"model_info": {"id": "prefixed-chat-id", "mode": "chat"},
|
|
}
|
|
]
|
|
)
|
|
|
|
response: Final = router.completion(model="prefixed-chat", messages=[{"role": "user", "content": "Say ok"}])
|
|
|
|
assert json.loads(responses_route.calls[0].request.read())["model"] == "gpt-5.6"
|
|
assert response.choices[0].message.content == "ok"
|
|
|
|
|
|
def test_a_chat_pin_keeps_a_plain_gpt_5_4_chat_request_on_chat_completions() -> None:
|
|
"""Without tools or a reasoning summary nothing forces the Responses API, so the deployment's own
|
|
mode decides and the shared ``responses`` row is left alone."""
|
|
shared_mode = litellm.model_cost["gpt-5.4"]["mode"]
|
|
info, model = responses_api_bridge_check(model="gpt-5.4", custom_llm_provider="openai", deployment_model_info=_CHAT)
|
|
assert (info["mode"], model) == ("chat", "gpt-5.4")
|
|
assert litellm.model_cost["gpt-5.4"]["mode"] == shared_mode
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"model, custom_llm_provider",
|
|
[
|
|
("gpt-5.1-codex", "azure"),
|
|
("o3-pro", "openai"),
|
|
("gpt-5.4-pro", "openai"),
|
|
("eu/gpt-5-codex", "azure"),
|
|
("us/gpt-5.4-pro", "azure"),
|
|
("databricks-gpt-5-3-codex", "databricks"),
|
|
],
|
|
)
|
|
def test_a_chat_pin_cannot_pull_a_responses_only_model_off_the_responses_api(
|
|
model: str, custom_llm_provider: str
|
|
) -> None:
|
|
"""These rows list only ``/v1/responses`` in ``supported_endpoints``, or are ``responses`` rows with no
|
|
endpoint list at all, so a deployment pin to chat has nowhere to send the request and the bridge keeps it."""
|
|
cost_map: Final = cast(dict[str, dict[str, object]], litellm.model_cost)
|
|
assert not backend_serves_chat_completions(
|
|
cost_map[model if custom_llm_provider == "openai" else f"{custom_llm_provider}/{model}"]
|
|
)
|
|
info, routed_model = responses_api_bridge_check(
|
|
model=model,
|
|
custom_llm_provider=custom_llm_provider,
|
|
api_base="https://example.openai.azure.com" if custom_llm_provider == "azure" else None,
|
|
deployment_model_info=_CHAT,
|
|
)
|
|
assert (info["mode"], routed_model) == ("responses", model)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"shared_model_info, expected",
|
|
[
|
|
({}, True),
|
|
({"mode": "chat"}, True),
|
|
({"mode": "responses"}, False),
|
|
({"supported_endpoints": ["/v1/chat/completions", "/v1/responses"]}, True),
|
|
({"supported_endpoints": ["/v1/responses", "/v1/batch"]}, False),
|
|
({"supported_endpoints": "/v1/chat/completions"}, True),
|
|
],
|
|
)
|
|
def test_backend_serves_chat_completions_reads_the_shared_row(
|
|
shared_model_info: Mapping[str, JsonValue], expected: bool
|
|
) -> None:
|
|
assert backend_serves_chat_completions(shared_model_info) is expected
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"extra_body, expected",
|
|
[
|
|
({"reasoning_effort": {"effort": "low", "summary": "auto"}}, {"effort": "low", "summary": "auto"}),
|
|
({"reasoning_effort": "low"}, "low"),
|
|
({"reasoning_effort": 5}, None),
|
|
({"reasoning_effort": ["low"]}, None),
|
|
({}, None),
|
|
("reasoning_effort=low", None),
|
|
(None, None),
|
|
],
|
|
ids=["dict", "string", "int", "list", "absent", "not-a-mapping", "no-extra-body"],
|
|
)
|
|
def test_bridge_reasoning_effort_reads_only_a_string_or_mapping_effort_nested_in_extra_body(
|
|
extra_body: JsonValue, expected: JsonValue
|
|
) -> None:
|
|
assert bridge_reasoning_effort(None, extra_body, custom_llm_provider="openai", api_base=None) == expected
|
|
|
|
|
|
@pytest.mark.parametrize("asynchronous", [False, True])
|
|
@pytest.mark.parametrize("stream", [False, True])
|
|
@pytest.mark.parametrize("prefix", ["", "responses/"])
|
|
@pytest.mark.parametrize("catalog_mode", [None, "chat", "responses"])
|
|
@pytest.mark.asyncio
|
|
async def test_chatgpt_completion_routes_to_responses_without_a_provider_catalog_entry(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
tmp_path: Path,
|
|
respx_mock: respx.MockRouter,
|
|
asynchronous: bool,
|
|
stream: bool,
|
|
prefix: str,
|
|
catalog_mode: str | None,
|
|
) -> None:
|
|
model: Final = "test-chatgpt-routing"
|
|
monkeypatch.setenv("CHATGPT_TOKEN_DIR", str(tmp_path))
|
|
monkeypatch.setenv("CHATGPT_API_BASE", "https://chatgpt.example")
|
|
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
|
|
(tmp_path / "auth.json").write_text(
|
|
json.dumps({"access_token": "fake-access-token", "expires_at": 253402300799, "account_id": "fake-account"})
|
|
)
|
|
monkeypatch.delitem(litellm.model_cost, f"chatgpt/{model}", raising=False)
|
|
monkeypatch.delitem(litellm.model_cost, model, raising=False)
|
|
if catalog_mode is not None:
|
|
monkeypatch.setitem(litellm.model_cost, model, {"mode": catalog_mode, "litellm_provider": "openai"})
|
|
litellm.get_model_info.cache_clear()
|
|
payload: Final = {
|
|
"id": "resp_test",
|
|
"object": "response",
|
|
"created_at": 1,
|
|
"status": "completed",
|
|
"model": model,
|
|
"output": [
|
|
{
|
|
"type": "message",
|
|
"id": "msg_test",
|
|
"status": "completed",
|
|
"role": "assistant",
|
|
"content": [{"type": "output_text", "text": "hello", "annotations": []}],
|
|
}
|
|
],
|
|
"usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2},
|
|
}
|
|
events: Final = (
|
|
{"type": "response.created", "response": {**payload, "status": "in_progress", "output": []}},
|
|
{
|
|
"type": "response.output_text.delta",
|
|
"delta": "hello",
|
|
"item_id": "msg_test",
|
|
"output_index": 0,
|
|
"content_index": 0,
|
|
},
|
|
{"type": "response.completed", "response": payload},
|
|
)
|
|
upstream: Final = respx_mock.post("https://chatgpt.example/responses").respond(
|
|
200,
|
|
headers={"content-type": "text/event-stream"},
|
|
text="".join(f"event: {event['type']}\ndata: {json.dumps(event)}\n\n" for event in events),
|
|
)
|
|
kwargs: Final = {
|
|
"model": f"chatgpt/{prefix}{model}",
|
|
"messages": [{"role": "user", "content": "Say hello"}],
|
|
"api_base": "https://chatgpt.example",
|
|
"stream": stream,
|
|
"num_retries": 0,
|
|
}
|
|
response: Final = await litellm.acompletion(**kwargs) if asynchronous else litellm.completion(**kwargs)
|
|
result: Final = (
|
|
litellm.stream_chunk_builder([chunk async for chunk in response] if asynchronous else list(response))
|
|
if stream
|
|
else response
|
|
)
|
|
assert result is not None
|
|
assert result.choices[0].message.content == "hello"
|
|
assert upstream.call_count == 1
|
|
sent: Final = json.loads(upstream.calls[0].request.content)
|
|
assert sent["model"] == model
|
|
assert sent["store"] is False
|
|
assert sent["input"] == [
|
|
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Say hello"}]}
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("provider", ["openai", "azure", "xai", "github_copilot"])
|
|
def test_missing_catalog_entry_does_not_force_other_providers_to_responses(provider: str) -> None:
|
|
info, model = responses_api_bridge_check(model="test-chatgpt-routing-control", custom_llm_provider=provider)
|
|
assert (info.get("mode"), model) == (None, "test-chatgpt-routing-control")
|
|
|
|
|
|
_GPT_5_6_CHUNKS: Final = (
|
|
{
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion.chunk",
|
|
"created": 1677652288,
|
|
"model": "gpt-5.6",
|
|
"choices": [{"index": 0, "delta": {"role": "assistant", "content": "Answer"}, "finish_reason": None}],
|
|
},
|
|
{
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion.chunk",
|
|
"created": 1677652288,
|
|
"model": "gpt-5.6",
|
|
"choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}],
|
|
},
|
|
)
|
|
|
|
|
|
def _openai_chat_upstream(respx_mock: respx.MockRouter, stream: bool) -> respx.Route:
|
|
route: Final = respx_mock.post("https://api.openai.com/v1/chat/completions")
|
|
if stream:
|
|
return route.respond(
|
|
200,
|
|
headers={"content-type": "text/event-stream"},
|
|
text="".join(f"data: {json.dumps(chunk)}\n\n" for chunk in _GPT_5_6_CHUNKS) + "data: [DONE]\n\n",
|
|
)
|
|
return route.respond(
|
|
200,
|
|
json={
|
|
"id": "chatcmpl-123",
|
|
"object": "chat.completion",
|
|
"created": 1677652288,
|
|
"model": "gpt-5.6",
|
|
"choices": [{"index": 0, "message": {"role": "assistant", "content": "Answer"}, "finish_reason": "stop"}],
|
|
"usage": {"prompt_tokens": 9, "completion_tokens": 1, "total_tokens": 10},
|
|
},
|
|
)
|
|
|
|
|
|
async def _bridged_responses_call(asynchronous: bool, stream: bool, **kwargs: object) -> None:
|
|
if not asynchronous:
|
|
response = litellm.responses(
|
|
input="Hello", stream=stream, api_key="fake-provider-api-key", num_retries=0, **kwargs
|
|
)
|
|
_ = list(response) if stream else response
|
|
return
|
|
response = await litellm.aresponses(
|
|
input="Hello", stream=stream, api_key="fake-provider-api-key", num_retries=0, **kwargs
|
|
)
|
|
_ = [event async for event in response] if stream else response
|
|
|
|
|
|
@pytest.mark.parametrize("verbosity", ["low", "high"])
|
|
@pytest.mark.parametrize("asynchronous", [False, True])
|
|
@pytest.mark.parametrize("stream", [False, True])
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_sends_text_verbosity_as_chat_verbosity(
|
|
verbosity: str, asynchronous: bool, stream: bool, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
|
|
upstream: Final = _openai_chat_upstream(respx_mock, stream)
|
|
|
|
await _bridged_responses_call(
|
|
asynchronous, stream, model="openai/gpt-5.6", use_chat_completions_api=True, text={"verbosity": verbosity}
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "gpt-5.6",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
"verbosity": verbosity,
|
|
**({"stream": True, "stream_options": {"include_usage": True}} if stream else {}),
|
|
}
|
|
|
|
|
|
_JSON_SCHEMA_TEXT_FORMAT: Final = {
|
|
"type": "json_schema",
|
|
"name": "answer",
|
|
"schema": {"type": "object", "properties": {"answer": {"type": "string"}}},
|
|
"strict": True,
|
|
}
|
|
_JSON_SCHEMA_RESPONSE_FORMAT: Final = {
|
|
"type": "json_schema",
|
|
"json_schema": {
|
|
"name": "answer",
|
|
"schema": {"type": "object", "properties": {"answer": {"type": "string"}}},
|
|
"strict": True,
|
|
},
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("text", "expected_fields"),
|
|
[
|
|
pytest.param(
|
|
{"verbosity": "low", "format": _JSON_SCHEMA_TEXT_FORMAT},
|
|
{"response_format": _JSON_SCHEMA_RESPONSE_FORMAT, "verbosity": "low"},
|
|
id="verbosity-and-format",
|
|
),
|
|
pytest.param(
|
|
{"format": _JSON_SCHEMA_TEXT_FORMAT}, {"response_format": _JSON_SCHEMA_RESPONSE_FORMAT}, id="format-only"
|
|
),
|
|
pytest.param(None, {}, id="no-text"),
|
|
],
|
|
)
|
|
def test_bridge_maps_text_format_alongside_verbosity(
|
|
text: dict[str, object] | None,
|
|
expected_fields: dict[str, object],
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
respx_mock: respx.MockRouter,
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = _openai_chat_upstream(respx_mock, stream=False)
|
|
|
|
litellm.responses(
|
|
model="openai/gpt-5.6",
|
|
input="Hello",
|
|
use_chat_completions_api=True,
|
|
api_key="fake-provider-api-key",
|
|
num_retries=0,
|
|
**({"text": text} if text is not None else {}),
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "gpt-5.6",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
**expected_fields,
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize("asynchronous", [False, True])
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_rejects_text_verbosity_the_provider_does_not_support_when_drop_params_is_off(
|
|
asynchronous: bool, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
with pytest.raises(litellm.UnsupportedParamsError) as raised:
|
|
await _bridged_responses_call(
|
|
asynchronous,
|
|
False,
|
|
model="databricks/my-custom-model",
|
|
text={"verbosity": "low"},
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
)
|
|
|
|
assert upstream.call_count == 0, "the provider must not be called with a verbosity it does not support"
|
|
assert raised.value.status_code == 400
|
|
assert "verbosity" in str(raised.value)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("call_kwargs", "global_drop_params", "expected_fields"),
|
|
[
|
|
pytest.param({"drop_params": True}, False, {}, id="request-drop-params"),
|
|
pytest.param({}, True, {}, id="global-drop-params"),
|
|
pytest.param({"allowed_openai_params": ["verbosity"]}, False, {"verbosity": "low"}, id="allowed-openai-params"),
|
|
],
|
|
)
|
|
def test_bridge_text_verbosity_follows_provider_param_validation(
|
|
call_kwargs: dict[str, object],
|
|
global_drop_params: bool,
|
|
expected_fields: dict[str, object],
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
respx_mock: respx.MockRouter,
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", global_drop_params)
|
|
upstream: Final = _databricks_chat_upstream(respx_mock)
|
|
|
|
response: Final = litellm.responses(
|
|
model="databricks/my-custom-model",
|
|
input="Hello",
|
|
text={"verbosity": "low"},
|
|
api_base="https://example.databricks.test/serving-endpoints",
|
|
api_key="fake-databricks-api-key",
|
|
num_retries=0,
|
|
**call_kwargs,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "my-custom-model",
|
|
"messages": [{"role": "user", "content": "Hello"}],
|
|
**expected_fields,
|
|
}
|
|
assert response.output[0].content[0].text == "Answer"
|
|
|
|
|
|
def test_native_responses_route_keeps_text_verbosity_nested(
|
|
monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
upstream: Final = respx_mock.post("https://api.openai.com/v1/responses").respond(
|
|
200,
|
|
json={
|
|
"id": "resp_1",
|
|
"object": "response",
|
|
"created_at": 1,
|
|
"status": "completed",
|
|
"model": "gpt-5.6",
|
|
"output": [
|
|
{
|
|
"type": "message",
|
|
"id": "msg_1",
|
|
"status": "completed",
|
|
"role": "assistant",
|
|
"content": [{"type": "output_text", "text": "ok", "annotations": []}],
|
|
}
|
|
],
|
|
"usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2},
|
|
},
|
|
)
|
|
|
|
litellm.responses(
|
|
model="openai/gpt-5.6",
|
|
input="Hello",
|
|
text={"verbosity": "low"},
|
|
api_key="fake-provider-api-key",
|
|
num_retries=0,
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "gpt-5.6",
|
|
"input": "Hello",
|
|
"text": {"verbosity": "low"},
|
|
}
|
|
|
|
|
|
_CLIENT_TOOL_SEARCH: Final = {
|
|
"type": "tool_search",
|
|
"execution": "client",
|
|
"description": "Search the deferred app tools.",
|
|
"parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize("verbosity", ["low", "high"])
|
|
@pytest.mark.asyncio
|
|
async def test_bridge_sends_text_verbosity_on_a_client_tool_search_follow_up_turn(
|
|
verbosity: str, monkeypatch: pytest.MonkeyPatch, respx_mock: respx.MockRouter
|
|
) -> None:
|
|
monkeypatch.setattr(litellm, "drop_params", False)
|
|
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
|
|
upstream: Final = _openai_chat_upstream(respx_mock, stream=False)
|
|
earlier_turn: Final = {
|
|
"request_id": "chatcmpl-earlier-turn",
|
|
"call_type": "aresponses",
|
|
"session_id": "earlier-session",
|
|
"proxy_server_request": {"input": "Hi", "model": "gpt-5.6"},
|
|
"response": {
|
|
"id": "chatcmpl-earlier-turn",
|
|
"object": "response",
|
|
"output": [
|
|
{
|
|
"type": "message",
|
|
"role": "assistant",
|
|
"status": "completed",
|
|
"content": [{"type": "output_text", "text": "Hi there.", "annotations": []}],
|
|
}
|
|
],
|
|
},
|
|
}
|
|
|
|
with patch(
|
|
"litellm.proxy.proxy_server.prisma_client",
|
|
MagicMock(db=MagicMock(query_raw=AsyncMock(return_value=[earlier_turn]))),
|
|
):
|
|
await _bridged_responses_call(
|
|
True,
|
|
False,
|
|
model="openai/gpt-5.6",
|
|
use_chat_completions_api=True,
|
|
previous_response_id="chatcmpl-earlier-turn",
|
|
tools=[_CLIENT_TOOL_SEARCH],
|
|
text={"verbosity": verbosity},
|
|
)
|
|
|
|
assert upstream.call_count == 1
|
|
assert json.loads(upstream.calls[0].request.read()) == {
|
|
"model": "gpt-5.6",
|
|
"messages": [
|
|
{"role": "user", "content": "Hi"},
|
|
{"role": "assistant", "content": [{"type": "text", "text": "Hi there."}]},
|
|
{"role": "user", "content": "Hello"},
|
|
],
|
|
"tools": [
|
|
{
|
|
"type": "function",
|
|
"function": {
|
|
"name": "tool_search",
|
|
"description": _CLIENT_TOOL_SEARCH["description"],
|
|
"parameters": _CLIENT_TOOL_SEARCH["parameters"],
|
|
},
|
|
}
|
|
],
|
|
"verbosity": verbosity,
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("model", "bridged"), [("chat-latest", True), ("gpt-chat-latest", False), ("my-gpt-chat-latest", False)]
|
|
)
|
|
def test_only_openais_own_chat_latest_sends_a_reasoning_summary_to_the_responses_api(model: str, bridged: bool) -> None:
|
|
info, _ = responses_api_bridge_check(
|
|
model=model, custom_llm_provider="openai", reasoning_effort="medium", reasoning_summary="auto"
|
|
)
|
|
assert (info.get("mode") == "responses") is bridged
|