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 img URL for tests
Ishaan Jafferbadbadba0dd3
diff --git a/cookbook/LiteLLM_HuggingFace.ipynb b/cookbook/LiteLLM_HuggingFace.ipynbindex d608c2675a1..bf8482a5f11 100644--- a/cookbook/LiteLLM_HuggingFace.ipynb+++ b/cookbook/LiteLLM_HuggingFace.ipynb@@ -131,7 +131,7 @@" {\n"," \"type\": \"image_url\",\n"," \"image_url\": {\n",- " \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n",+ " \"url\": \"https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png\",\n"," },\n"," },\n"," ],\n",diff --git a/docs/my-website/docs/completion/vision.md b/docs/my-website/docs/completion/vision.mdindex 76700084868..90d6b2393fb 100644--- a/docs/my-website/docs/completion/vision.md+++ b/docs/my-website/docs/completion/vision.md@@ -31,7 +31,7 @@ response = completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]@@ -92,7 +92,7 @@ response = client.chat.completions.create({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]@@ -230,7 +230,7 @@ response = completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png","format": "image/jpeg"}}@@ -292,7 +292,7 @@ response = client.chat.completions.create({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png","format": "image/jpeg"}}diff --git a/docs/my-website/docs/providers/azure/azure.md b/docs/my-website/docs/providers/azure/azure.mdindex 2f845357328..0ff5b2a5a77 100644--- a/docs/my-website/docs/providers/azure/azure.md+++ b/docs/my-website/docs/providers/azure/azure.md@@ -251,7 +251,7 @@ response = completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]diff --git a/docs/my-website/docs/providers/groq.md b/docs/my-website/docs/providers/groq.mdindex 59668b5eb5f..ebed31f720f 100644--- a/docs/my-website/docs/providers/groq.md+++ b/docs/my-website/docs/providers/groq.md@@ -290,7 +290,7 @@ response = completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]@@ -342,7 +342,7 @@ response = client.chat.completions.create({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]diff --git a/docs/my-website/docs/providers/huggingface.md b/docs/my-website/docs/providers/huggingface.mdindex 399d49b5f46..985351e9f69 100644--- a/docs/my-website/docs/providers/huggingface.md+++ b/docs/my-website/docs/providers/huggingface.md@@ -130,7 +130,7 @@ messages=[{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png",}},],@@ -250,7 +250,7 @@ messages=[{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png",}},],diff --git a/docs/my-website/docs/providers/openai.md b/docs/my-website/docs/providers/openai.mdindex 9303cdffadc..6f46807c89a 100644--- a/docs/my-website/docs/providers/openai.md+++ b/docs/my-website/docs/providers/openai.md@@ -252,7 +252,7 @@ response = completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.mdindex 874b637e4db..70babea3814 100644--- a/docs/my-website/docs/providers/vertex.md+++ b/docs/my-website/docs/providers/vertex.md@@ -1741,7 +1741,7 @@ response = litellm.completion({"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"}}]diff --git a/tests/code_coverage_tests/test_aio_http_image_conversion.py b/tests/code_coverage_tests/test_aio_http_image_conversion.pyindex fc9f110427e..e4f1bb62a7c 100644--- a/tests/code_coverage_tests/test_aio_http_image_conversion.py+++ b/tests/code_coverage_tests/test_aio_http_image_conversion.py@@ -96,7 +96,7 @@ async def test_aiohttp(urls: list[str], iterations: int = 3) -> list[float]:async def run_comparison():urls = [- "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"] * 150print("Testing asyncified version...")diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.pyindex 1511ccdc3bc..ffdcd1b79ff 100644--- a/tests/llm_translation/base_llm_unit_tests.py+++ b/tests/llm_translation/base_llm_unit_tests.py@@ -854,7 +854,7 @@ class BaseLLMChatTest(ABC):"image_url",["http://img1.etsystatic.com/260/0/7813604/il_fullxfull.4226713999_q86e.jpg",- "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png",],)@pytest.mark.flaky(retries=4, delay=2)@@ -920,7 +920,7 @@ class BaseLLMChatTest(ABC):os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"litellm.model_cost = litellm.get_model_cost_map(url="")- image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ image_url = "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"base_completion_call_args = self.get_base_completion_call_args()if not supports_vision(base_completion_call_args["model"], None):diff --git a/tests/llm_translation/test_bedrock_completion.py b/tests/llm_translation/test_bedrock_completion.pyindex 7f20dfaa0f5..9242950daac 100644--- a/tests/llm_translation/test_bedrock_completion.py+++ b/tests/llm_translation/test_bedrock_completion.py@@ -2582,7 +2582,7 @@ async def test_bedrock_image_url_sync_client():{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"},},],diff --git a/tests/llm_translation/test_fireworks_ai_translation.py b/tests/llm_translation/test_fireworks_ai_translation.pyindex 903b83aea67..b9abbd501d0 100644--- a/tests/llm_translation/test_fireworks_ai_translation.py+++ b/tests/llm_translation/test_fireworks_ai_translation.py@@ -218,7 +218,7 @@ def test_global_disable_flag_with_transform_messages_helper(monkeypatch):{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"},},],diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.pyindex a3f3ba5729a..7166007961b 100644--- a/tests/local_testing/test_completion.py+++ b/tests/local_testing/test_completion.py@@ -981,7 +981,7 @@ def test_completion_gpt4_vision():{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png"},},],diff --git a/tests/local_testing/test_embedding.py b/tests/local_testing/test_embedding.pyindex 29b0f45a57a..13ff81bc695 100644--- a/tests/local_testing/test_embedding.py+++ b/tests/local_testing/test_embedding.py@@ -829,12 +829,26 @@ def test_fireworks_embeddings():pytest.fail(f"Error occurred: {e}")-def test_watsonx_embeddings():+def test_watsonx_embeddings(monkeypatch):from litellm.llms.custom_httpx.http_handler import HTTPHandler+ # Mock the IAM token generation to avoid actual API calls+ monkeypatch.setenv("WATSONX_API_KEY", "mock-api-key")+ monkeypatch.setenv("WATSONX_TOKEN", "mock-watsonx-token")+ monkeypatch.setenv("WATSONX_API_BASE", "https://us-south.ml.cloud.ibm.com")+ monkeypatch.setenv("WATSONX_PROJECT_ID", "mock-project-id")+client = HTTPHandler()++ # Track the actual request made+ captured_request = {}def mock_wx_embed_request(url: str, **kwargs):+ # Capture request details for verification+ captured_request["url"] = url+ captured_request["headers"] = kwargs.get("headers", {})+ captured_request["data"] = kwargs.get("data")+mock_response = MagicMock()mock_response.status_code = 200mock_response.headers = {"Content-Type": "application/json"}@@ -852,12 +866,16 @@ def test_watsonx_embeddings():response = litellm.embedding(model="watsonx/ibm/slate-30m-english-rtrvr",input=["good morning from litellm"],- token="secret-token",client=client,)print(f"response: {response}")assert isinstance(response.usage, litellm.Usage)++ # Verify the request was made correctly+ assert "Authorization" in captured_request["headers"]+ assert captured_request["headers"]["Authorization"] == "Bearer mock-watsonx-token"+ assert "us-south.ml.cloud.ibm.com" in captured_request["url"]except litellm.RateLimitError as e:passexcept Exception as e:@@ -865,9 +883,15 @@ def test_watsonx_embeddings():@pytest.mark.asyncio-async def test_watsonx_aembeddings():+async def test_watsonx_aembeddings(monkeypatch):from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler+ # Mock the IAM token generation to avoid actual API calls+ monkeypatch.setenv("WATSONX_API_KEY", "mock-api-key")+ monkeypatch.setenv("WATSONX_TOKEN", "mock-watsonx-token")+ monkeypatch.setenv("WATSONX_API_BASE", "https://us-south.ml.cloud.ibm.com")+ monkeypatch.setenv("WATSONX_PROJECT_ID", "mock-project-id")+client = AsyncHTTPHandler()def mock_async_client(*args, **kwargs):@@ -897,7 +921,6 @@ async def test_watsonx_aembeddings():response = await litellm.aembedding(model="watsonx/ibm/slate-30m-english-rtrvr",input=["good morning from litellm"],- token="secret-token",client=client,)mock_client.assert_called_once()diff --git a/tests/local_testing/test_function_calling.py b/tests/local_testing/test_function_calling.pyindex a8172c16afd..e2f9c6d834e 100644--- a/tests/local_testing/test_function_calling.py+++ b/tests/local_testing/test_function_calling.py@@ -707,11 +707,17 @@ def test_passing_tool_result_as_list(model):@pytest.mark.parametrize("sync_mode", [True, False])@pytest.mark.asyncio@pytest.mark.flaky(retries=6, delay=1)-async def test_watsonx_tool_choice(sync_mode):+async def test_watsonx_tool_choice(sync_mode, monkeypatch):from litellm.llms.custom_httpx.http_handler import HTTPHandler, AsyncHTTPHandlerimport jsonfrom litellm import acompletion, completion+ # Mock the IAM token generation to avoid actual API calls+ monkeypatch.setenv("WATSONX_API_KEY", "mock-api-key")+ monkeypatch.setenv("WATSONX_TOKEN", "mock-watsonx-token")+ monkeypatch.setenv("WATSONX_API_BASE", "https://us-south.ml.cloud.ibm.com")+ monkeypatch.setenv("WATSONX_PROJECT_ID", "mock-project-id")+litellm.set_verbose = Truetools = [{@@ -761,7 +767,7 @@ async def test_watsonx_tool_choice(sync_mode):mock_completion.assert_called_once()print(mock_completion.call_args.kwargs)json_data = json.loads(mock_completion.call_args.kwargs["data"])- json_data["tool_choice_option"] == "auto"+ assert json_data["tool_choice_option"] == "auto"except Exception as e:print(e)if "The read operation timed out" in str(e):diff --git a/tests/test_litellm/litellm_core_utils/test_token_counter.py b/tests/test_litellm/litellm_core_utils/test_token_counter.pyindex 8cd623267ba..ddfef431a6d 100644--- a/tests/test_litellm/litellm_core_utils/test_token_counter.py+++ b/tests/test_litellm/litellm_core_utils/test_token_counter.py@@ -270,7 +270,7 @@ def test_gpt_vision_token_counting():{"type": "text", "text": "What’s in this image?"},{"type": "image_url",- "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "image_url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png",},],}diff --git a/tests/test_litellm/test_main.py b/tests/test_litellm/test_main.pyindex be4bb4e48a6..2a59a0b74f0 100644--- a/tests/test_litellm/test_main.py+++ b/tests/test_litellm/test_main.py@@ -160,7 +160,7 @@ async def test_url_with_format_param(model, sync_mode, monkeypatch):{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png","format": "image/png",},},@@ -243,7 +243,7 @@ async def test_url_with_format_param_openai(model, sync_mode):{"type": "image_url","image_url": {- "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",+ "url": "https://awsmp-logos.s3.amazonaws.com/seller-xw5kijmvmzasy/c233c9ade2ccb5491072ae232c814942.png","format": "image/png",},},