Skip to content

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]

revert(ocr): stop forwarding client= on the Python path

Yujong Leefb41bc3ed658
diff --git a/litellm/ocr/main.py b/litellm/ocr/main.py
index 851d9162964..06830ed4b53 100644
--- a/litellm/ocr/main.py
+++ b/litellm/ocr/main.py
@@ -25,7 +25,6 @@ from litellm.llms.base_llm.ocr.transformation import (
OCRResponse,
parse_ocr_request_format,
)
-from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
from litellm.types.router import GenericLiteLLMParams
from litellm.types.utils import CustomPricingLiteLLMParams
@@ -53,11 +52,6 @@ class _PreparedOCRRequest:
litellm_logging_obj: LiteLLMLoggingObj
-def _supplied_client(kwargs: Mapping[str, object]) -> HTTPHandler | AsyncHTTPHandler | None:
- candidate: Final = kwargs.get("client")
- return candidate if isinstance(candidate, (HTTPHandler, AsyncHTTPHandler)) else None
-
-
def _prepare_ocr_request(
model: str,
document: Mapping[str, object],
@@ -244,7 +238,6 @@ async def aocr(
api_key=prepared.api_key,
api_base=prepared.api_base,
custom_llm_provider=prepared.custom_llm_provider,
- client=_supplied_client(kwargs),
aocr=True,
headers=prepared.extra_headers,
provider_config=prepared.provider_config,
@@ -411,7 +404,6 @@ def ocr(
api_key=prepared.api_key,
api_base=prepared.api_base,
custom_llm_provider=prepared.custom_llm_provider,
- client=_supplied_client(kwargs),
aocr=_is_async,
headers=prepared.extra_headers,
provider_config=prepared.provider_config,
diff --git a/tests/test_litellm/ocr/test_main.py b/tests/test_litellm/ocr/test_main.py
index 32e5637ee09..5531a2639c0 100644
--- a/tests/test_litellm/ocr/test_main.py
+++ b/tests/test_litellm/ocr/test_main.py
@@ -113,35 +113,6 @@ async def test_python_request_response_and_callbacks(
assert logger.log_pre_api_call.call_count == 1
[email protected]("asynchronous", [False, True])
-async def test_python_uses_the_supplied_client(provider: Mock, asynchronous: bool) -> None:
- supplied: Final = Mock(return_value=provider.return_value)
- transport: Final = httpx.MockTransport(supplied)
- arguments: Final = {
- "model": "mistral/mistral-ocr-latest",
- "document": dict(PRICING_DOCUMENT),
- "api_key": "test-key",
- "api_base": "https://ocr.test/v1",
- }
-
- async def call() -> OCRResponse:
- if not asynchronous:
- with httpx.Client(transport=transport) as sync_client:
- return litellm.ocr(**arguments, client=HTTPHandler(client=sync_client))
- async with httpx.AsyncClient(transport=transport) as async_client:
- handler: Final = AsyncHTTPHandler()
- await handler.client.aclose()
- handler.client = async_client
- return await litellm.aocr(**arguments, client=handler)
-
- response: Final = await call()
- assert response.pages[0].markdown == "parsed document"
- assert supplied.call_count == 1
- assert str(supplied.call_args.args[0].url) == "https://ocr.test/v1/ocr"
- assert provider.call_count == 0
-
-
@pytest.mark.asyncio
@pytest.mark.parametrize("asynchronous", [False, True])
async def test_python_provider_errors_keep_public_exception(provider: Mock, asynchronous: bool) -> None: