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
test(rust): assert native serving via the x-litellm-rust response marker (#46531)
yujonglee8410b5ba5e1a
diff --git a/scripts/benchmark_ocr_callbacks.py b/scripts/benchmark_ocr_callbacks.pyindex 5db182c3d0e..85cd4ffae49 100644--- a/scripts/benchmark_ocr_callbacks.py+++ b/scripts/benchmark_ocr_callbacks.py@@ -23,7 +23,7 @@ from collections.abc import Sequencefrom dataclasses import asdict, dataclassfrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServerfrom pathlib import Path-from typing import Final, cast+from typing import FinalSIZES: Final = (1024,@@ -50,15 +50,12 @@ class Server(ThreadingHTTPServer):def __init__(self) -> None:super().__init__(("127.0.0.1", 0), Handler)- self.user_agents: set[str] = set()class Handler(BaseHTTPRequestHandler):protocol_version = "HTTP/1.1"def do_POST(self) -> None:- server: Final = cast(Server, self.server)- server.user_agents.add(self.headers.get("User-Agent", ""))length: Final = int(self.headers["Content-Length"])body: Final = self.rfile.read(length)request: Final = json.loads(body)@@ -105,10 +102,16 @@ def percentile(values: Sequence[float], quantile: float) -> float:return ordered[index]-def verify(response: object) -> None:+def verify(response: object, expected_transport: str) -> None:+ from litellm.router_utils.add_retry_fallback_headers import get_hidden_params_dict+pages: Final = getattr(response, "pages", ())if len(pages) != 1 or getattr(pages[0], "markdown", None) != EXPECTED_MARKDOWN:raise RuntimeError(f"unexpected OCR response: {response!r}")+ additional_headers: Final = get_hidden_params_dict(response).get("additional_headers")+ rust_served: Final = isinstance(additional_headers, dict) and additional_headers.get("x-litellm-rust") == "true"+ if rust_served != (expected_transport == "rust"):+ raise RuntimeError(f"unexpected transport for {expected_transport}: rust_marker={rust_served}")def summarize(label: str, mode: str, size: int, samples: Sequence[float]) -> Result:@@ -125,7 +128,9 @@ def summarize(label: str, mode: str, size: int, samples: Sequence[float]) -> Res)-def sync_samples(litellm: object, url: str, request_document: dict[str, str], count: int) -> tuple[float, ...]:+def sync_samples(+ litellm: object, url: str, request_document: dict[str, str], count: int, expected_transport: str+) -> tuple[float, ...]:samples: list[float] = []for _ in range(count):started: Final = time.perf_counter()@@ -133,11 +138,13 @@ def sync_samples(litellm: object, url: str, request_document: dict[str, str], comodel=MODEL, document=request_document, api_base=url, api_key="mock-key", timeout=30)samples.append(time.perf_counter() - started)- verify(response)+ verify(response, expected_transport)return tuple(samples)-async def async_samples(litellm: object, url: str, request_document: dict[str, str], count: int) -> tuple[float, ...]:+async def async_samples(+ litellm: object, url: str, request_document: dict[str, str], count: int, expected_transport: str+) -> tuple[float, ...]:samples: list[float] = []for _ in range(count):started: Final = time.perf_counter()@@ -145,7 +152,7 @@ async def async_samples(litellm: object, url: str, request_document: dict[str, smodel=MODEL, document=request_document, api_base=url, api_key="mock-key", timeout=30)samples.append(time.perf_counter() - started)- verify(response)+ verify(response, expected_transport)return tuple(samples)@@ -218,17 +225,20 @@ async def main() -> int:try:for size in args.sizes:request_document: Final = document(size)- sync_samples(litellm, url, request_document, args.warmup)+ sync_samples(litellm, url, request_document, args.warmup, args.expected_transport)sync_result: Final = summarize(- args.label, "sync", size, sync_samples(litellm, url, request_document, args.iterations)+ args.label,+ "sync",+ size,+ sync_samples(litellm, url, request_document, args.iterations, args.expected_transport),)results.append(sync_result)- await async_samples(litellm, url, request_document, args.warmup)+ await async_samples(litellm, url, request_document, args.warmup, args.expected_transport)async_result: Final = summarize(args.label,"async",size,- await async_samples(litellm, url, request_document, args.iterations),+ await async_samples(litellm, url, request_document, args.iterations, args.expected_transport),)results.append(async_result)sys.stdout.write(json.dumps(asdict(sync_result)) + "\n")@@ -256,12 +266,6 @@ async def main() -> int:raise RuntimeError("callback registrations appeared in the no-callback case")await GLOBAL_LOGGING_WORKER.stop()- user_agents: Final = tuple(sorted(server.user_agents))- python_transport: Final = any(- value.startswith("python-httpx") or value.startswith("litellm/") for value in user_agents- )- if (args.expected_transport == "python") != python_transport:- raise RuntimeError(f"unexpected transport for {args.label}: user_agents={user_agents}")artifact: Final = {"label": args.label,"callbacks": args.callbacks,@@ -275,11 +279,10 @@ async def main() -> int:"package": str(package),"native": native_path,"native_sha256": native_sha256,- "user_agents": user_agents,"results": tuple(asdict(result) for result in results),}args.output.write_text(json.dumps(artifact, indent=2) + "\n")- sys.stdout.write(json.dumps({key: artifact[key] for key in ("label", "version", "package", "user_agents")}) + "\n")+ sys.stdout.write(json.dumps({key: artifact[key] for key in ("label", "version", "package")}) + "\n")sys.stdout.write(f"results={args.output}\n")sys.stdout.flush()return 0diff --git a/tests/test_litellm_rust/messages/test_callbacks.py b/tests/test_litellm_rust/messages/test_callbacks.pyindex b3cd7bd01f9..6c317c3b9d9 100644--- a/tests/test_litellm_rust/messages/test_callbacks.py+++ b/tests/test_litellm_rust/messages/test_callbacks.py@@ -5,7 +5,6 @@ import pytestimport litellmfrom litellm.integrations.custom_logger import CustomLogger-from litellm.router_utils.add_retry_fallback_headers import get_hidden_params_dictfrom litellm.rust_bridge import catalogfrom litellm.rust_bridge.catalog import Route, RouteRulefrom litellm.rust_bridge.configuration import Rollout@@ -19,6 +18,7 @@ from tests.test_litellm_rust.support.requests import (MESSAGES_RESPONSE,request_body,)+from tests.test_litellm_rust.support.served import assert_served_nativelypytestmark = pytest.mark.requires_rust_extension@@ -48,11 +48,6 @@ def arguments(server: RecordingServer, **kwargs: object) -> dict[str, object]:}-def assert_served_natively(server: RecordingServer) -> None:- assert len(server.requests) == 1- assert not server.requests[0].headers.get("user-agent", "").startswith("python-httpx")--@pytest.mark.asyncioasync def test_native_messages_callbacks_see_the_provider_request_and_the_public_response(messages_server: RecordingServer,@@ -63,7 +58,7 @@ async def test_native_messages_callbacks_see_the_provider_request_and_the_public**arguments(messages_server, callbacks=[recorder], litellm_call_id="messages-success"))- assert_served_natively(messages_server)+ assert_served_natively(messages_server, response)assert response["content"] == MESSAGES_RESPONSE["content"]sent: Final = messages_server.requests[0]assert sent.path == "/v1/messages"@@ -107,7 +102,7 @@ async def test_native_messages_provider_error_reaches_caller_and_failure_callbacwith pytest.raises(litellm.BadRequestError) as raised:await litellm.anthropic.messages.acreate(**arguments(messages_server, callbacks=[Observe()]))- assert_served_natively(messages_server)+ assert len(messages_server.requests) == 1assert [phase for phase, _ in observed] == ["sync", "async"]assert all(error is raised.value for _, error in observed)@@ -127,14 +122,13 @@ async def test_native_messages_stream_relays_provider_events_and_logs_success_on**arguments(messages_server, stream=True, callbacks=[recorder]))assert isinstance(stream, AsyncIterator)- assert get_hidden_params_dict(stream)["additional_headers"]["x-litellm-rust"] == "true"first: Final = await anext(stream)await drain_logging()assert "async_log_success_event" not in recorder.namesrest: Final = [chunk async for chunk in stream]assert first + b"".join(rest) == sse_payload()- assert_served_natively(messages_server)+ assert_served_natively(messages_server, stream)assert messages_server.requests[0].body["stream"] is Truesuccess: Final = await recorder.wait_for_async("async_log_success_event")assert len(success) == 1@@ -171,10 +165,9 @@ def test_native_sync_messages_stream_relays_provider_events_and_logs_success_oncstream: Final = litellm.anthropic.messages.create(**arguments(messages_server, stream=True, callbacks=[recorder]))assert isinstance(stream, Iterator)- assert get_hidden_params_dict(stream)["additional_headers"]["x-litellm-rust"] == "true"assert b"".join(stream) == sse_payload()- assert_served_natively(messages_server)+ assert_served_natively(messages_server, stream)assert len(recorder.wait_for("async_log_success_event")) == 1@@ -183,7 +176,7 @@ def test_native_sync_messages_returns_the_provider_message(messages_server: Recoresponse: Final = litellm.anthropic.messages.create(**arguments(messages_server, callbacks=[recorder]))- assert_served_natively(messages_server)+ assert_served_natively(messages_server, response)assert response["content"] == MESSAGES_RESPONSE["content"]assert len(recorder.wait_for("log_success_event")) == 1@@ -216,7 +209,7 @@ async def test_native_messages_failing_pre_call_logger_does_not_fail_the_call(meresponse: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, callbacks=[Broken()]))- assert_served_natively(messages_server)+ assert_served_natively(messages_server, response)assert response["content"] == MESSAGES_RESPONSE["content"]@@ -259,9 +252,9 @@ async def test_native_messages_does_not_restore_keywords_deleted_by_a_pre_call_hstream=False,)with rebound(litellm, "callbacks", [DropKeywords()]):- await litellm.anthropic.messages.acreate(**call_arguments)+ response: Final = await litellm.anthropic.messages.acreate(**call_arguments)- assert_served_natively(messages_server)+ assert_served_natively(messages_server, response)sent: Final = messages_server.requests[0]assert sent.body == {"model": MESSAGES_MODEL.removeprefix("anthropic/"),diff --git a/tests/test_litellm_rust/messages/test_request_shaping.py b/tests/test_litellm_rust/messages/test_request_shaping.pyindex 3584a2a8593..3ae17e0f614 100644--- a/tests/test_litellm_rust/messages/test_request_shaping.py+++ b/tests/test_litellm_rust/messages/test_request_shaping.py@@ -17,6 +17,7 @@ from litellm.rust_bridge.configuration import Rolloutfrom tests.test_litellm_rust.support.isolation import reboundfrom tests.test_litellm_rust.support.recording_server import RecordingServer, ResponseSpecfrom tests.test_litellm_rust.support.requests import MESSAGES, MESSAGES_RESPONSE+from tests.test_litellm_rust.support.served import assert_served_nativelypytestmark = pytest.mark.requires_rust_extension@@ -47,10 +48,9 @@ def arguments(server: RecordingServer, **kwargs: object) -> dict[str, object]:}-def sent(server: RecordingServer) -> tuple[dict[str, object], dict[str, str]]:- assert len(server.requests) == 1+def sent(server: RecordingServer, response: object) -> tuple[dict[str, object], dict[str, str]]:+ assert_served_natively(server, response)request: Final = server.requests[0]- assert not request.headers.get("user-agent", "").startswith("python-httpx")assert isinstance(request.body, dict)return request.body, request.headers@@ -59,9 +59,9 @@ def sent(server: RecordingServer) -> tuple[dict[str, object], dict[str, str]]:async def test_reasoning_effort_becomes_adaptive_thinking_and_effort_on_the_wire(messages_server: RecordingServer,) -> None:- await litellm.anthropic.messages.acreate(**arguments(messages_server, reasoning_effort="high"))+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, reasoning_effort="high"))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert "reasoning_effort" not in bodyassert body["thinking"] == {"type": "adaptive", "display": "summarized"}assert body["output_config"] == {"effort": "high"}@@ -71,7 +71,7 @@ async def test_reasoning_effort_becomes_adaptive_thinking_and_effort_on_the_wireasync def test_claude_code_adaptive_payload_is_downgraded_to_a_capped_budget_for_a_legacy_model(messages_server: RecordingServer,) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server,model=LEGACY_THINKING_MODEL,@@ -82,7 +82,7 @@ async def test_claude_code_adaptive_payload_is_downgraded_to_a_capped_budget_for))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert body["thinking"] == {"type": "enabled", "budget_tokens": 2999}assert "output_config" not in bodyassert "temperature" not in body@@ -90,11 +90,11 @@ async def test_claude_code_adaptive_payload_is_downgraded_to_a_capped_budget_for@pytest.mark.asyncioasync def test_removed_sampling_params_are_dropped_under_drop_params(messages_server: RecordingServer) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, temperature=0.2, top_p=0.9, top_k=5, drop_params=True))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert not {"temperature", "top_p", "top_k"} & body.keys()@@ -130,9 +130,9 @@ async def test_replayed_history_is_sanitized_before_it_reaches_the_provider({"role": "user", "content": [{"type": "tool_result", "tool_use_id": "functions.Bash:0", "content": "ok"}]},]- await litellm.anthropic.messages.acreate(**arguments(messages_server, messages=history))+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, messages=history))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert body["messages"] == [{"role": "user", "content": "run it"},{"role": "assistant", "content": [{"type": "tool_use", "id": "functions_Bash_0", "name": "Bash", "input": {}}]},@@ -142,7 +142,7 @@ async def test_replayed_history_is_sanitized_before_it_reaches_the_provider(@pytest.mark.asyncioasync def test_feature_betas_merge_into_the_forwarded_beta_header(messages_server: RecordingServer) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server,output_format={"type": "json_schema", "schema": {"type": "object"}},@@ -150,15 +150,17 @@ async def test_feature_betas_merge_into_the_forwarded_beta_header(messages_serve))- _, headers = sent(messages_server)+ _, headers = sent(messages_server, response)assert headers["anthropic-beta"] == "structured-outputs-2025-11-13,web-search-2025-03-05"@pytest.mark.asyncioasync def test_oauth_token_authenticates_as_a_bearer_with_the_oauth_beta(messages_server: RecordingServer) -> None:- await litellm.anthropic.messages.acreate(**arguments(messages_server, api_key="sk-ant-oat01-token"))+ response: Final = await litellm.anthropic.messages.acreate(+ **arguments(messages_server, api_key="sk-ant-oat01-token")+ )- _, headers = sent(messages_server)+ _, headers = sent(messages_server, response)assert "x-api-key" not in headersassert headers["authorization"] == "Bearer sk-ant-oat01-token"assert headers["anthropic-beta"] == "oauth-2025-04-20"@@ -167,11 +169,11 @@ async def test_oauth_token_authenticates_as_a_bearer_with_the_oauth_beta(message@pytest.mark.asyncioasync def test_metadata_is_reduced_to_the_fields_anthropic_accepts(messages_server: RecordingServer) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, metadata={"user_id": "u-1", "trace_id": "internal"}))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert body["metadata"] == {"user_id": "u-1"}@@ -179,17 +181,17 @@ async def test_metadata_is_reduced_to_the_fields_anthropic_accepts(messages_servasync def test_additional_drop_params_remove_nested_fields_from_the_wire(messages_server: RecordingServer) -> None:tools: Final = [{"name": "lookup", "input_schema": {"type": "object"}, "input_examples": [{"q": "x"}]}]- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server, tools=tools, additional_drop_params=["tools[*].input_examples"]))- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert body["tools"] == [{"name": "lookup", "input_schema": {"type": "object"}}]@pytest.mark.asyncioasync def test_provider_specific_headers_scoped_to_anthropic_reach_the_wire(messages_server: RecordingServer) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server,provider_specific_header=[@@ -199,7 +201,7 @@ async def test_provider_specific_headers_scoped_to_anthropic_reach_the_wire(mess))- _, headers = sent(messages_server)+ _, headers = sent(messages_server, response)assert headers["x-scoped"] == "yes"assert "x-other" not in headers@@ -208,7 +210,7 @@ async def test_provider_specific_headers_scoped_to_anthropic_reach_the_wire(messasync def test_scoped_headers_override_extra_headers_which_override_forwarded_headers(messages_server: RecordingServer,) -> None:- await litellm.anthropic.messages.acreate(+ response: Final = await litellm.anthropic.messages.acreate(**arguments(messages_server,headers={"x-priority": "forwarded", "x-forwarded-only": "kept"},@@ -217,7 +219,7 @@ async def test_scoped_headers_override_extra_headers_which_override_forwarded_he))- _, headers = sent(messages_server)+ _, headers = sent(messages_server, response)assert {name: headers.get(name) for name in ("x-priority", "x-forwarded-only", "x-extra-only")} == {"x-priority": "scoped","x-forwarded-only": "kept",@@ -298,20 +300,12 @@ async def test_native_messages_observes_runtime_capabilities_and_separate_caller@pytest.mark.asyncioasync def test_native_messages_reads_optional_positional_body_parameters(messages_server: RecordingServer) -> None:- from litellm.messages.dispatch import _MESSAGES, _public_request- from litellm.rust_bridge.messages.entrypoints import NATIVE_AMESSAGES-- native: Final = NATIVE_AMESSAGES.load()- assert native is not Nonemetadata: Final = {"user_id": "caller"}args: Final = (16, MESSAGES, "anthropic/claude-test", metadata, None, False, "Be brief", 0.25)kwargs: Final = {"api_key": "test-key", "api_base": messages_server.base_url}- call: Final = _public_request(_MESSAGES, args, kwargs)- assert call is not None-- await native(call)+ response: Final = await litellm.anthropic.messages.acreate(*args, **kwargs)- body, _ = sent(messages_server)+ body, _ = sent(messages_server, response)assert body["temperature"] == args[7]assert body["system"] == args[6]assert body["metadata"] == metadatadiff --git a/tests/test_litellm_rust/ocr/test_dispatch.py b/tests/test_litellm_rust/ocr/test_dispatch.pyindex 7b4b9fab579..a29a45376d9 100644--- a/tests/test_litellm_rust/ocr/test_dispatch.py+++ b/tests/test_litellm_rust/ocr/test_dispatch.py@@ -6,6 +6,7 @@ import litellmfrom litellm.llms.base_llm.ocr.transformation import OCRResponsefrom tests.test_litellm_rust.support.recording_server import RecordingServer, ResponseSpecfrom tests.test_litellm_rust.support.requests import OCR_DOCUMENT, OCR_MODEL, OCR_RESPONSE+from tests.test_litellm_rust.support.served import assert_served_nativelypytestmark = pytest.mark.requires_rust_extension@@ -28,8 +29,7 @@ def test_public_ocr_uses_native_route_independently_of_flag(ocr_server: Recordinassert isinstance(response, OCRResponse)assert response.pages[0].markdown == "native OCR response"- assert len(ocr_server.requests) == 1- assert not ocr_server.requests[0].headers.get("user-agent", "").startswith("python-httpx")+ assert_served_natively(ocr_server, response)@pytest.mark.asynciodiff --git a/tests/test_litellm_rust/ocr/test_requests.py b/tests/test_litellm_rust/ocr/test_requests.pyindex 7c62133202d..8c4f3a403d6 100644--- a/tests/test_litellm_rust/ocr/test_requests.py+++ b/tests/test_litellm_rust/ocr/test_requests.py@@ -19,6 +19,7 @@ from tests.test_litellm_rust.support.requests import (call_native_aocr,call_native_ocr,)+from tests.test_litellm_rust.support.served import assert_served_nativelypytestmark = pytest.mark.requires_rust_extension@@ -169,7 +170,7 @@ async def test_ocr_contract_native_format_supported(assert response.get_provider_native_response() == payloadassert len(ocr_server.requests) == 1if ocr_backend:- assert_native_request(ocr_server)+ assert_served_natively(ocr_server, response)@pytest.mark.asyncio@@ -217,7 +218,7 @@ async def test_native_azure_ocr_uses_token_provider_result_as_bearer_token(assert calls == ["token"]assert response.pages[0].markdown == "native OCR response"- assert_native_request(ocr_server)+ assert_served_natively(ocr_server, response)assert ocr_server.requests[0].headers["authorization"] == "Bearer callback-token"@@ -227,11 +228,6 @@ def ocr_server(recording_server: RecordingServer) -> RecordingServer:return recording_server-def assert_native_request(server: RecordingServer) -> None:- assert len(server.requests) == 1- assert not server.requests[0].headers.get("user-agent", "").startswith("python-httpx")--def test_native_ocr_maps_provider_400_with_public_provider_details(ocr_server: RecordingServer) -> None:ocr_server.enqueue(ResponseSpec(body={"message": "invalid OCR request"}, status=400))@@ -252,7 +248,7 @@ def test_native_ocr_encodes_python_file_input_and_drops_unknown_arguments(ocr_se)assert response.pages[0].markdown == "native OCR response"- assert_native_request(ocr_server)+ assert_served_natively(ocr_server, response)assert ocr_server.requests[0].body == {"model": "mistral-ocr-latest","document": {"type": "image_url", "image_url": "data:image/png;base64,YWJj"},@@ -614,7 +610,7 @@ async def test_native_settings_observe_mutation_between_calls(monkeypatch.setattr(litellm, "user_url_allowed_hosts", "EXAMPLE.TEST.")response: Final = await call_native(ocr_server, asynchronous, num_retries=0)assert response.pages[0].markdown == "native OCR response"- assert_native_request(ocr_server)+ assert_served_natively(ocr_server, response)monkeypatch.setattr(litellm, "ssl_certificate", 1)with pytest.raises(ValueError, match=r"http_settings\.ssl_certificate"):await call_native(ocr_server, asynchronous, num_retries=0)diff --git a/tests/test_litellm_rust/support/served.py b/tests/test_litellm_rust/support/served.pynew file mode 100644index 00000000000..d3c568937f3--- /dev/null+++ b/tests/test_litellm_rust/support/served.py@@ -0,0 +1,11 @@+from typing import Final++from litellm.router_utils.add_retry_fallback_headers import get_hidden_params_dict+from tests.test_litellm_rust.support.recording_server import RecordingServer+++def assert_served_natively(server: RecordingServer, response: object) -> None:+ assert len(server.requests) == 1+ additional_headers: Final = get_hidden_params_dict(response).get("additional_headers")+ assert isinstance(additional_headers, dict)+ assert additional_headers.get("x-litellm-rust") == "true"diff --git a/tests/test_litellm_rust/test_fork_guard.py b/tests/test_litellm_rust/test_fork_guard.pyindex 02c454e0460..8e1251de8c2 100644--- a/tests/test_litellm_rust/test_fork_guard.py+++ b/tests/test_litellm_rust/test_fork_guard.py@@ -66,14 +66,11 @@ _SDK_CONTRACT = textwrap.dedent(import litellmfrom litellm.rust_bridge.fork_guard import ForkedAfterNativeRuntimeStarted+ from litellm.router_utils.add_retry_fallback_headers import get_hidden_params_dictclass Handler(BaseHTTPRequestHandler):def do_POST(self):self.rfile.read(int(self.headers["Content-Length"]))- if self.headers.get("User-Agent", "").startswith("python-httpx"):- self.send_response(418)- self.end_headers()- returnbody = json.dumps({"pages": [{"index": 0, "markdown": "native", "images": [], "dimensions": None}],"model": "mistral-ocr-latest",@@ -108,7 +105,10 @@ _SDK_CONTRACT = textwrap.dedent(return REFUSEDexcept Exception:return OTHER- return SERVED if response.pages[0].markdown == "native" else OTHER+ return SERVED if (+ response.pages[0].markdown == "native"+ and get_hidden_params_dict(response).get("additional_headers", {}).get("x-litellm-rust") == "true"+ ) else OTHERdef forked(asynchronous):pid = os.fork()