From 7bbd8262ed44d060f7ff4d98668efca46f57273d Mon Sep 17 00:00:00 2001 From: Cole McIntosh <82463175+colesmcintosh@users.noreply.github.com> Date: Tue, 3 Jun 2025 21:39:47 -0600 Subject: [PATCH] Add Claude 4 Sonnet & Opus, DeepSeek R1, and fix Llama Vision model pricing configurations (#11339) * fix: update model path for llama-v3p2-90b-vision-instruct in pricing configuration (missing fireworks_ai/ prefix) * feat: add deepseek-r1-0528 model configuration to pricing JSON * feat: add configurations for new Claude 4 model alias to pricing JSON * undo prefix change * fix: update supports_response_schema to false in pricing JSON for litellm_provider * update supports_tool_choice and supports_response_schema * Update model configuration to disable function calling and tool choice for multiple models in fireworks_ai. Adjusted supported parameters in FireworksAIConfig to conditionally include tools and tool_choice based on model compatibility. * Refactor FireworksAIConfig to use supports_function_calling from utils * Enhance FireworksAIConfig to conditionally support tool_choice based on model capabilities --- .../llms/fireworks_ai/chat/transformation.py | 16 ++- model_prices_and_context_window.json | 113 ++++++++++++++---- 2 files changed, 102 insertions(+), 27 deletions(-) diff --git a/litellm/llms/fireworks_ai/chat/transformation.py b/litellm/llms/fireworks_ai/chat/transformation.py index 3bb1b5f378..31d749032b 100644 --- a/litellm/llms/fireworks_ai/chat/transformation.py +++ b/litellm/llms/fireworks_ai/chat/transformation.py @@ -25,6 +25,7 @@ from litellm.types.utils import ( ModelResponse, ProviderSpecificModelInfo, ) +from litellm.utils import supports_function_calling, supports_tool_choice from ...openai.chat.gpt_transformation import OpenAIGPTConfig from ..common_utils import FireworksAIException @@ -83,10 +84,9 @@ class FireworksAIConfig(OpenAIGPTConfig): return super().get_config() def get_supported_openai_params(self, model: str): - return [ + # Base parameters supported by all models + supported_params = [ "stream", - "tools", - "tool_choice", "max_completion_tokens", "max_tokens", "temperature", @@ -102,6 +102,16 @@ class FireworksAIConfig(OpenAIGPTConfig): "prompt_truncate_length", "context_length_exceeded_behavior", ] + + # Only add tools for models that support function calling + if supports_function_calling(model=model, custom_llm_provider="fireworks_ai"): + supported_params.append("tools") + + # Only add tool_choice for models that explicitly support it + if supports_tool_choice(model=model, custom_llm_provider="fireworks_ai"): + supported_params.append("tool_choice") + + return supported_params def map_openai_params( self, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 66c8daf18b..79f657e1d9 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -5031,6 +5031,58 @@ "supports_reasoning": true, "supports_computer_use": true }, + "claude-4-opus-20250514": { + "max_tokens": 32000, + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "input_cost_per_token": 1.5e-05, + "output_cost_per_token": 7.5e-05, + "search_context_cost_per_query": { + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01, + "search_context_size_high": 0.01 + }, + "cache_creation_input_token_cost": 1.875e-05, + "cache_read_input_token_cost": 1.5e-06, + "litellm_provider": "anthropic", + "mode": "chat", + "supports_function_calling": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 159, + "supports_assistant_prefill": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_reasoning": true, + "supports_computer_use": true + }, + "claude-4-sonnet-20250514": { + "max_tokens": 64000, + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "input_cost_per_token": 3e-06, + "output_cost_per_token": 1.5e-05, + "search_context_cost_per_query": { + "search_context_size_low": 0.01, + "search_context_size_medium": 0.01, + "search_context_size_high": 0.01 + }, + "cache_creation_input_token_cost": 3.75e-06, + "cache_read_input_token_cost": 3e-07, + "litellm_provider": "anthropic", + "mode": "chat", + "supports_function_calling": true, + "supports_vision": true, + "tool_use_system_prompt_tokens": 159, + "supports_assistant_prefill": true, + "supports_pdf_input": true, + "supports_prompt_caching": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_reasoning": true, + "supports_computer_use": true + }, "claude-3-7-sonnet-latest": { "supports_computer_use": true, "max_tokens": 128000, @@ -12689,10 +12741,10 @@ "output_cost_per_token": 1e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/llama-v3p2-3b-instruct": { "max_tokens": 16384, @@ -12702,10 +12754,10 @@ "output_cost_per_token": 1e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/llama-v3p1-8b-instruct": { "max_tokens": 16384, @@ -12715,10 +12767,10 @@ "output_cost_per_token": 1e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/llama-v3p2-11b-vision-instruct": { "max_tokens": 16384, @@ -12728,13 +12780,13 @@ "output_cost_per_token": 2e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_vision": true, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, - "accounts/fireworks/models/llama-v3p2-90b-vision-instruct": { + "fireworks_ai/accounts/fireworks/models/llama-v3p2-90b-vision-instruct": { "max_tokens": 16384, "max_input_tokens": 16384, "max_output_tokens": 16384, @@ -12742,7 +12794,7 @@ "output_cost_per_token": 9e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_tool_choice": false, "supports_vision": true, "supports_response_schema": true, "source": "https://fireworks.ai/pricing" @@ -12781,10 +12833,10 @@ "output_cost_per_token": 9e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/qwen2p5-coder-32b-instruct": { "max_tokens": 4096, @@ -12794,10 +12846,10 @@ "output_cost_per_token": 9e-07, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/yi-large": { "max_tokens": 32768, @@ -12807,10 +12859,10 @@ "output_cost_per_token": 3e-06, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/deepseek-coder-v2-instruct": { "max_tokens": 65536, @@ -12820,10 +12872,10 @@ "output_cost_per_token": 1.2e-06, "litellm_provider": "fireworks_ai", "mode": "chat", - "supports_function_calling": true, + "supports_function_calling": false, "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/deepseek-v3": { "max_tokens": 8192, @@ -12835,7 +12887,7 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/deepseek-r1": { "max_tokens": 20480, @@ -12847,7 +12899,7 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/deepseek-r1-basic": { "max_tokens": 20480, @@ -12859,7 +12911,19 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false + }, + "fireworks_ai/accounts/fireworks/models/deepseek-r1-0528": { + "max_tokens": 160000, + "max_input_tokens": 160000, + "max_output_tokens": 160000, + "input_cost_per_token": 3e-06, + "output_cost_per_token": 8e-06, + "litellm_provider": "fireworks_ai", + "mode": "chat", + "source": "https://fireworks.ai/pricing", + "supports_tool_choice": false, + "supports_response_schema": true }, "fireworks_ai/accounts/fireworks/models/llama-v3p1-405b-instruct": { "max_tokens": 16384, @@ -12871,7 +12935,8 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": true, + "supports_function_calling": true }, "fireworks_ai/accounts/fireworks/models/llama4-maverick-instruct-basic": { "max_tokens": 131072, @@ -12883,7 +12948,7 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/accounts/fireworks/models/llama4-scout-instruct-basic": { "max_tokens": 131072, @@ -12895,7 +12960,7 @@ "mode": "chat", "supports_response_schema": true, "source": "https://fireworks.ai/pricing", - "supports_tool_choice": true + "supports_tool_choice": false }, "fireworks_ai/nomic-ai/nomic-embed-text-v1.5": { "max_tokens": 8192,