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(main.py): fix passing openrouter specific params (#8184)
Krish Dholakiae4566d7b1ca0
diff --git a/litellm/main.py b/litellm/main.pyindex 35ff3f7b950..a37d8f1eb11 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -2206,7 +2206,7 @@ def completion( # type: ignore # noqa: PLR0915data = {"model": model, "messages": messages, **optional_params}## COMPLETION CALL- response = openai_chat_completions.completion(+ response = openai_like_chat_completion.completion(model=model,messages=messages,headers=headers,@@ -2221,6 +2221,8 @@ def completion( # type: ignore # noqa: PLR0915acompletion=acompletion,timeout=timeout, # type: ignorecustom_llm_provider="openrouter",+ custom_prompt_dict=custom_prompt_dict,+ encoding=encoding,)## LOGGINGlogging.post_call(diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.pyindex dd924a6d5d9..a8359b43c42 100644--- a/tests/local_testing/test_completion.py+++ b/tests/local_testing/test_completion.py@@ -2605,6 +2605,21 @@ def test_completion_openrouter1():pytest.fail(f"Error occurred: {e}")+def test_completion_openrouter_reasoning_effort():+ try:+ litellm.set_verbose = True+ response = completion(+ model="openrouter/deepseek/deepseek-r1",+ messages=messages,+ include_reasoning=True,+ max_tokens=5,+ )+ # Add any assertions here to check the response+ print(response)+ except Exception as e:+ pytest.fail(f"Error occurred: {e}")++# test_completion_openrouter1()diff --git a/tests/local_testing/test_get_model_info.py b/tests/local_testing/test_get_model_info.pyindex 910158cdddb..edf9183ad23 100644--- a/tests/local_testing/test_get_model_info.py+++ b/tests/local_testing/test_get_model_info.py@@ -376,3 +376,24 @@ def test_get_model_info_huggingface_models(monkeypatch):providers=["huggingface"],**info,)+++ "model, provider",+ [+ ("bedrock/us-east-2/us.anthropic.claude-3-haiku-20240307-v1:0", None),+ (+ "bedrock/us-east-2/us.anthropic.claude-3-haiku-20240307-v1:0",+ "bedrock",+ ),+ ],+)+def test_get_model_info_cost_calculator_bedrock_region_cris_stripped(model, provider):+ """+ ensure cross region inferencing model is used correctly+ Relevant Issue: https://github.com/BerriAI/litellm/issues/8115+ """+ info = get_model_info(model=model, custom_llm_provider=provider)+ print("info", info)+ assert info["key"] == "us.anthropic.claude-3-haiku-20240307-v1:0"+ assert info["litellm_provider"] == "bedrock"