From b4970f603302569ff1960730c7c21feb76c41284 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Sat, 6 Dec 2025 16:08:28 -0800 Subject: [PATCH] amazon nova api fix --- docs/my-website/docs/providers/amazon_nova.md | 14 +++++++------- litellm/__init__.py | 4 ++-- litellm/constants.py | 2 +- .../litellm_core_utils/get_llm_provider_logic.py | 4 ++-- litellm/llms/amazon_nova/chat/transformation.py | 2 +- litellm/llms/amazon_nova/cost_calculation.py | 2 +- litellm/main.py | 5 ++++- .../model_prices_and_context_window_backup.json | 8 ++++---- litellm/types/utils.py | 2 +- model_prices_and_context_window.json | 8 ++++---- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/docs/my-website/docs/providers/amazon_nova.md b/docs/my-website/docs/providers/amazon_nova.md index 30479ebd771..69c61d9d978 100644 --- a/docs/my-website/docs/providers/amazon_nova.md +++ b/docs/my-website/docs/providers/amazon_nova.md @@ -6,7 +6,7 @@ import TabItem from '@theme/TabItem'; | Property | Details | |-------|-------| | Description | Amazon Nova is a family of foundation models built by Amazon that deliver frontier intelligence and industry-leading price performance. | -| Provider Route on LiteLLM | `amazon-nova/` | +| Provider Route on LiteLLM | `amazon_nova/` | | Provider Doc | [Amazon Nova ↗](https://docs.aws.amazon.com/nova/latest/userguide/what-is-nova.html) | | Supported OpenAI Endpoints | `/chat/completions`, `v1/responses` | | Other Supported Endpoints | `v1/messages`, `/generateContent` | @@ -32,7 +32,7 @@ from litellm import completion os.environ["AMAZON_NOVA_API_KEY"] = "your-api-key" response = completion( - model="amazon-nova/nova-micro-v1", + model="amazon_nova/nova-micro-v1", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Hello, how are you?"} @@ -51,7 +51,7 @@ print(response) model_list: - model_name: amazon-nova-micro litellm_params: - model: amazon-nova/nova-micro-v1 + model: amazon_nova/nova-micro-v1 api_key: os.environ/AMAZON_NOVA_API_KEY ``` ### 2. Start the proxy @@ -82,7 +82,7 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \ | Model Name | Usage | Context Window | |------------|-------|----------------| -| Nova Micro | `completion(model="amazon-nova/nova-micro-v1", messages=messages)` | 128K tokens | +| Nova Micro | `completion(model="amazon_nova/nova-micro-v1", messages=messages)` | 128K tokens | | Nova Lite | `completion(model="amazon-nova/nova-lite-v1", messages=messages)` | 300K tokens | | Nova Pro | `completion(model="amazon-nova/nova-pro-v1", messages=messages)` | 300K tokens | | Nova Premier | `completion(model="amazon-nova/nova-premier-v1", messages=messages)` | 1M tokens | @@ -99,7 +99,7 @@ from litellm import completion os.environ["AMAZON_NOVA_API_KEY"] = "your-api-key" response = completion( - model="amazon-nova/nova-micro-v1", + model="amazon_nova/nova-micro-v1", messages=[ {"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Tell me about machine learning"} @@ -164,7 +164,7 @@ tools = [ ] response = completion( - model="amazon-nova/nova-micro-v1", + model="amazon_nova/nova-micro-v1", messages=[ {"role": "user", "content": "What's the weather like in San Francisco?"} ], @@ -246,7 +246,7 @@ print(response) model_list: - model_name: amazon-nova-pro litellm_params: - model: amazon-nova/nova-pro-v1 + model: amazon_nova/nova-pro-v1 temperature: 0.8 max_tokens: 500 top_p: 0.9 diff --git a/litellm/__init__.py b/litellm/__init__.py index e4ad39d2534..a4ade3bccae 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -816,7 +816,7 @@ def add_known_models(): lemonade_models.add(key) elif value.get("litellm_provider") == "docker_model_runner": docker_model_runner_models.add(key) - elif value.get("litellm_provider") == "amazon-nova": + elif value.get("litellm_provider") == "amazon_nova": amazon_nova_models.add(key) @@ -1019,7 +1019,7 @@ models_by_provider: dict = { "ovhcloud": ovhcloud_models | ovhcloud_embedding_models, "lemonade": lemonade_models, "clarifai": clarifai_models, - "amazon-nova": amazon_nova_models, + "amazon_nova": amazon_nova_models, } # mapping for those models which have larger equivalents diff --git a/litellm/constants.py b/litellm/constants.py index a7cab1ca232..1c0f800eccd 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -414,7 +414,7 @@ LITELLM_CHAT_PROVIDERS = [ "ovhcloud", "lemonade", "docker_model_runner", - "amazon-nova", + "amazon_nova", ] LITELLM_EMBEDDING_PROVIDERS_SUPPORTING_INPUT_ARRAY_OF_TOKENS = [ diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.py index 52ba7a9cdbc..168c837f1e5 100644 --- a/litellm/litellm_core_utils/get_llm_provider_logic.py +++ b/litellm/litellm_core_utils/get_llm_provider_logic.py @@ -404,8 +404,8 @@ def get_llm_provider( # noqa: PLR0915 custom_llm_provider = "lemonade" elif model.startswith("clarifai/"): custom_llm_provider = "clarifai" - elif model.startswith("amazon-nova"): - custom_llm_provider = "amazon-nova" + elif model.startswith("amazon_nova"): + custom_llm_provider = "amazon_nova" if not custom_llm_provider: if litellm.suppress_debug_info is False: print() # noqa diff --git a/litellm/llms/amazon_nova/chat/transformation.py b/litellm/llms/amazon_nova/chat/transformation.py index 325b0cb14b0..6d321e298b8 100644 --- a/litellm/llms/amazon_nova/chat/transformation.py +++ b/litellm/llms/amazon_nova/chat/transformation.py @@ -41,7 +41,7 @@ class AmazonNovaChatConfig(OpenAILikeChatConfig): @property def custom_llm_provider(self) -> Optional[str]: - return "amazon-nova" + return "amazon_nova" @classmethod def get_config(cls): diff --git a/litellm/llms/amazon_nova/cost_calculation.py b/litellm/llms/amazon_nova/cost_calculation.py index 0b35d6ea00b..9d9cedde875 100644 --- a/litellm/llms/amazon_nova/cost_calculation.py +++ b/litellm/llms/amazon_nova/cost_calculation.py @@ -17,5 +17,5 @@ def cost_per_token(model: str, usage: "Usage") -> Tuple[float, float]: Follows the same logic as Anthropic's cost per token calculation. """ return generic_cost_per_token( - model=model, usage=usage, custom_llm_provider="amazon-nova" + model=model, usage=usage, custom_llm_provider="amazon_nova" ) \ No newline at end of file diff --git a/litellm/main.py b/litellm/main.py index b5d55f9f998..59838c2a035 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -52,10 +52,13 @@ from pydantic import BaseModel from typing_extensions import overload import litellm + # client must be imported from litellm as it's a decorator used at function definition time from litellm import client + # Other utils are imported directly to avoid circular imports from litellm.utils import exception_type, get_litellm_params, get_optional_params + # Logging is imported lazily when needed to avoid loading litellm_logging at import time if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging @@ -2662,7 +2665,7 @@ def completion( # type: ignore # noqa: PLR0915 ) response = model_response - elif custom_llm_provider == "amazon-nova": + elif custom_llm_provider == "amazon_nova": api_key = ( api_key or litellm.amazon_nova_api_key diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index e0df56dd7d7..79a6d2de06a 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -16957,7 +16957,7 @@ }, "amazon-nova/nova-micro-v1": { "input_cost_per_token": 3.5e-08, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 128000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16969,7 +16969,7 @@ }, "amazon-nova/nova-lite-v1": { "input_cost_per_token": 6e-08, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 300000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16983,7 +16983,7 @@ }, "amazon-nova/nova-premier-v1": { "input_cost_per_token": 2.5e-06, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 1000000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16997,7 +16997,7 @@ }, "amazon-nova/nova-pro-v1": { "input_cost_per_token": 8e-07, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 300000, "max_output_tokens": 10000, "max_tokens": 10000, diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 10081765d4d..5821ae3d233 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3002,7 +3002,7 @@ class LlmProviders(str, Enum): WANDB = "wandb" OVHCLOUD = "ovhcloud" LEMONADE = "lemonade" - AMAZON_NOVA = "amazon-nova" + AMAZON_NOVA = "amazon_nova" A2A_AGENT = "a2a_agent" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index e0df56dd7d7..79a6d2de06a 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -16957,7 +16957,7 @@ }, "amazon-nova/nova-micro-v1": { "input_cost_per_token": 3.5e-08, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 128000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16969,7 +16969,7 @@ }, "amazon-nova/nova-lite-v1": { "input_cost_per_token": 6e-08, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 300000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16983,7 +16983,7 @@ }, "amazon-nova/nova-premier-v1": { "input_cost_per_token": 2.5e-06, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 1000000, "max_output_tokens": 10000, "max_tokens": 10000, @@ -16997,7 +16997,7 @@ }, "amazon-nova/nova-pro-v1": { "input_cost_per_token": 8e-07, - "litellm_provider": "amazon-nova", + "litellm_provider": "amazon_nova", "max_input_tokens": 300000, "max_output_tokens": 10000, "max_tokens": 10000,