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_bedrock_passthrough_router
Ishaan Jafferda72a812c9dd
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex caca89d23f8..03a3399c717 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -21896,8 +21896,8 @@"input_cost_per_token_batches": 7.5e-06,"litellm_provider": "vertex_ai-anthropic_models","max_input_tokens": 200000,- "max_output_tokens": 4096,- "max_tokens": 4096,+ "max_output_tokens": 32000,+ "max_tokens": 32000,"mode": "chat","output_cost_per_token": 7.5e-05,"output_cost_per_token_batches": 3.75e-05,@@ -21913,8 +21913,8 @@"input_cost_per_token_batches": 7.5e-06,"litellm_provider": "vertex_ai-anthropic_models","max_input_tokens": 200000,- "max_output_tokens": 4096,- "max_tokens": 4096,+ "max_output_tokens": 32000,+ "max_tokens": 32000,"mode": "chat","output_cost_per_token": 7.5e-05,"output_cost_per_token_batches": 3.75e-05,diff --git a/tests/llm_translation/test_bedrock_completion.py b/tests/llm_translation/test_bedrock_completion.pyindex d41448727d5..81593fb3f41 100644--- a/tests/llm_translation/test_bedrock_completion.py+++ b/tests/llm_translation/test_bedrock_completion.py@@ -3232,6 +3232,60 @@ async def test_bedrock_passthrough(sync_mode: bool):assert response.status_code == 200+async def test_bedrock_passthrough_router():+ """+ Test bedrock passthrough using litellm.Router with async mode.+ Tests that the router:+ 1. Resolves the router model name to the actual deployment+ 2. Replaces the router model name in the endpoint with the actual deployment model+ """+ import litellm+ from litellm import Router++ litellm._turn_on_debug()++ router = Router(+ model_list=[+ {+ "model_name": "special-bedrock-model",+ "litellm_params": {+ "model": "bedrock/us.anthropic.claude-3-5-sonnet-20240620-v1:0",+ },+ }+ ]+ )++ data = {+ "max_tokens": 512,+ "messages": [{"role": "user", "content": "Hey"}],+ "system": [+ {+ "type": "text",+ "text": "Analyze if this message indicates a new conversation topic. If it does, extract a 2-3 word title that captures the new topic. Format your response as a JSON object with two fields: 'isNewTopic' (boolean) and 'title' (string, or null if isNewTopic is false). Only include these fields, no other text.",+ }+ ],+ "temperature": 0,+ "metadata": {+ "user_id": "5dd07c33da27e6d2968d94ea20bf47a7b090b6b158b82328d54da2909a108e84"+ },+ "anthropic_version": "bedrock-2023-05-31",+ "anthropic_beta": ["claude-code-20250219"],+ }++ # Endpoint uses the router model name which should be replaced with actual deployment+ response = await router.allm_passthrough_route(+ model="special-bedrock-model",+ method="POST",+ endpoint="/model/special-bedrock-model/invoke",+ data=data,+ )++ print(response.text)++ assert response.status_code == 200++@pytest.mark.asyncioasync def test_bedrock_converse__streaming_passthrough(monkeypatch):import litellm