Skip to content

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]

fix(snowflake): transform tool_choice string to object format (#23268)

stevejaker2341a38c0867
diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json
index b3125d4ad38..275c352b39e 100644
--- a/litellm/llms/openai_like/providers.json
+++ b/litellm/llms/openai_like/providers.json
@@ -94,5 +94,12 @@
"assemblyai": {
"base_url": "https://llm-gateway.assemblyai.com/v1",
"api_key_env": "ASSEMBLYAI_API_KEY"
+ },
+ "charity_engine": {
+ "base_url": "https://api.charityengine.services/remotejobs/v2/inference",
+ "api_key_env": "CHARITY_ENGINE_API_KEY",
+ "param_mappings": {
+ "max_completion_tokens": "max_tokens"
+ }
}
}
diff --git a/litellm/llms/snowflake/chat/transformation.py b/litellm/llms/snowflake/chat/transformation.py
index 62ede0aeaf8..e11cab4138d 100644
--- a/litellm/llms/snowflake/chat/transformation.py
+++ b/litellm/llms/snowflake/chat/transformation.py
@@ -208,27 +208,28 @@ class SnowflakeConfig(SnowflakeBaseConfig, OpenAIGPTConfig):
def _transform_tool_choice(
self, tool_choice: Union[str, Dict[str, Any]]
- ) -> Union[str, Dict[str, Any]]:
+ ) -> Dict[str, Any]:
"""
Transform OpenAI tool_choice format to Snowflake format.
+ Snowflake requires tool_choice to be an object, not a string.
+ Ref: https://docs.snowflake.com/en/developer-guide/snowflake-rest-api/reference/cortex-inference#post--api-v2-cortex-inference-complete-req-body-schema
+
Args:
tool_choice: Tool choice in OpenAI format (str or dict)
Returns:
- Tool choice in Snowflake format
-
- OpenAI format:
- {"type": "function", "function": {"name": "get_weather"}}
+ Tool choice in Snowflake format (always an object)
- Snowflake format:
- {"type": "tool", "name": ["get_weather"]}
+ OpenAI format (string): "auto", "required", "none"
+ OpenAI format (object): {"type": "function", "function": {"name": "get_weather"}}
- Note: String values ("auto", "required", "none") pass through unchanged.
+ Snowflake format (string values become objects): {"type": "auto"}
+ Snowflake format (specific tool): {"type": "tool", "name": ["get_weather"]}
"""
if isinstance(tool_choice, str):
- # "auto", "required", "none" pass through as-is
- return tool_choice
+ # Snowflake requires object format: {"type": "auto"} not string "auto"
+ return {"type": tool_choice}
if isinstance(tool_choice, dict):
if tool_choice.get("type") == "function":
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 177a2bf52e0..194af4895fe 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -4207,6 +4207,41 @@
"supports_tool_choice": true,
"supports_vision": true
},
+ "azure/gpt-5.3-chat": {
+ "cache_read_input_token_cost": 1.75e-07,
+ "cache_read_input_token_cost_priority": 3.5e-07,
+ "input_cost_per_token": 1.75e-06,
+ "input_cost_per_token_priority": 3.5e-06,
+ "litellm_provider": "azure",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "max_tokens": 16384,
+ "mode": "chat",
+ "output_cost_per_token": 1.4e-05,
+ "output_cost_per_token_priority": 2.8e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
"azure/gpt-5.3-codex": {
"cache_read_input_token_cost": 1.75e-07,
"input_cost_per_token": 1.75e-06,
@@ -4299,6 +4334,160 @@
"supports_vision": true,
"supports_web_search": true
},
+ "azure/gpt-5.4": {
+ "cache_read_input_token_cost": 2.5e-07,
+ "cache_read_input_token_cost_above_272k_tokens": 5e-07,
+ "cache_read_input_token_cost_priority": 5e-07,
+ "cache_read_input_token_cost_above_272k_tokens_priority": 1e-06,
+ "input_cost_per_token": 2.5e-06,
+ "input_cost_per_token_above_272k_tokens": 5e-06,
+ "input_cost_per_token_priority": 5e-06,
+ "input_cost_per_token_above_272k_tokens_priority": 1e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "chat",
+ "output_cost_per_token": 1.5e-05,
+ "output_cost_per_token_above_272k_tokens": 2.25e-05,
+ "output_cost_per_token_priority": 3e-05,
+ "output_cost_per_token_above_272k_tokens_priority": 4.5e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
+ "azure/gpt-5.4-2026-03-05": {
+ "cache_read_input_token_cost": 2.5e-07,
+ "cache_read_input_token_cost_above_272k_tokens": 5e-07,
+ "cache_read_input_token_cost_priority": 5e-07,
+ "cache_read_input_token_cost_above_272k_tokens_priority": 1e-06,
+ "input_cost_per_token": 2.5e-06,
+ "input_cost_per_token_above_272k_tokens": 5e-06,
+ "input_cost_per_token_priority": 5e-06,
+ "input_cost_per_token_above_272k_tokens_priority": 1e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "chat",
+ "output_cost_per_token": 1.5e-05,
+ "output_cost_per_token_above_272k_tokens": 2.25e-05,
+ "output_cost_per_token_priority": 3e-05,
+ "output_cost_per_token_above_272k_tokens_priority": 4.5e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
+ "azure/gpt-5.4-pro": {
+ "cache_read_input_token_cost": 3e-06,
+ "cache_read_input_token_cost_above_272k_tokens": 6e-06,
+ "input_cost_per_token": 3e-05,
+ "input_cost_per_token_above_272k_tokens": 6e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "responses",
+ "output_cost_per_token": 0.00018,
+ "output_cost_per_token_above_272k_tokens": 0.00027,
+ "supported_endpoints": [
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": false,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "azure/gpt-5.4-pro-2026-03-05": {
+ "cache_read_input_token_cost": 3e-06,
+ "cache_read_input_token_cost_above_272k_tokens": 6e-06,
+ "input_cost_per_token": 3e-05,
+ "input_cost_per_token_above_272k_tokens": 6e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "responses",
+ "output_cost_per_token": 0.00018,
+ "output_cost_per_token_above_272k_tokens": 0.00027,
+ "supported_endpoints": [
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": false,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
"azure/gpt-image-1": {
"cache_read_input_image_token_cost": 2.5e-06,
"cache_read_input_token_cost": 1.25e-06,
diff --git a/litellm/types/router.py b/litellm/types/router.py
index d917d845ad2..f0c1ea5e32a 100644
--- a/litellm/types/router.py
+++ b/litellm/types/router.py
@@ -8,7 +8,7 @@ from dataclasses import dataclass
from typing import Any, Dict, List, Literal, Optional, Tuple, Union, get_type_hints
import httpx
-from pydantic import BaseModel, ConfigDict, Field
+from pydantic import BaseModel, ConfigDict, Field, model_validator
from typing_extensions import Required, TypedDict
from litellm._uuid import uuid
@@ -16,7 +16,6 @@ from litellm._uuid import uuid
from .completion import CompletionRequest
from .embedding import EmbeddingRequest
from .llms.openai import OpenAIFileObject
-from .llms.vertex_ai import VERTEX_CREDENTIALS_TYPES
from .search import SearchProvider
from .utils import CustomPricingLiteLLMParams, ModelResponse
@@ -162,6 +161,9 @@ class CredentialLiteLLMParams(BaseModel):
watsonx_region_name: Optional[str] = None
+_RESERVED_INIT_KEYS = frozenset({"self", "params", "__class__"})
+
+
class GenericLiteLLMParams(CredentialLiteLLMParams, CustomPricingLiteLLMParams):
"""
LiteLLM Params without 'model' arg (used across completion / assistants api)
@@ -215,76 +217,21 @@ class GenericLiteLLMParams(CredentialLiteLLMParams, CustomPricingLiteLLMParams):
vector_store_id: Optional[str] = None
milvus_text_field: Optional[str] = None
- def __init__(
- self,
- custom_llm_provider: Optional[str] = None,
- max_retries: Optional[Union[int, str]] = None,
- tpm: Optional[int] = None,
- rpm: Optional[int] = None,
- api_key: Optional[str] = None,
- api_base: Optional[str] = None,
- api_version: Optional[str] = None,
- timeout: Optional[Union[float, str]] = None, # if str, pass in as os.environ/
- stream_timeout: Optional[Union[float, str]] = (
- None # timeout when making stream=True calls, if str, pass in as os.environ/
- ),
- organization: Optional[str] = None, # for openai orgs
- ## LOGGING PARAMS ##
- litellm_trace_id: Optional[str] = None,
- ## UNIFIED PROJECT/REGION ##
- region_name: Optional[str] = None,
- ## VERTEX AI ##
- vertex_project: Optional[str] = None,
- vertex_location: Optional[str] = None,
- vertex_credentials: Optional[VERTEX_CREDENTIALS_TYPES] = None,
- ## AWS BEDROCK / SAGEMAKER ##
- aws_access_key_id: Optional[str] = None,
- aws_secret_access_key: Optional[str] = None,
- aws_region_name: Optional[str] = None,
- ## IBM WATSONX ##
- watsonx_region_name: Optional[str] = None,
- input_cost_per_token: Optional[float] = None,
- output_cost_per_token: Optional[float] = None,
- input_cost_per_second: Optional[float] = None,
- output_cost_per_second: Optional[float] = None,
- max_file_size_mb: Optional[float] = None,
- # Deployment budgets
- max_budget: Optional[float] = None,
- budget_duration: Optional[str] = None,
- # Pass through params
- use_in_pass_through: Optional[bool] = False,
- # Dynamic param to force using litellm proxy
- use_litellm_proxy: Optional[bool] = False,
- # This will merge the reasoning content in the choices
- merge_reasoning_content_in_choices: Optional[bool] = False,
- model_info: Optional[Dict] = None,
- mock_response: Optional[Union[str, ModelResponse, Exception, Any]] = None,
- # auto-router params
- auto_router_config_path: Optional[str] = None,
- auto_router_config: Optional[str] = None,
- auto_router_default_model: Optional[str] = None,
- auto_router_embedding_model: Optional[str] = None,
- # complexity-router params
- complexity_router_config: Optional[Dict] = None,
- complexity_router_default_model: Optional[str] = None,
- # Batch/File API Params
- s3_bucket_name: Optional[str] = None,
- s3_encryption_key_id: Optional[str] = None,
- gcs_bucket_name: Optional[str] = None,
- **params,
- ):
- args = locals()
- args.pop("max_retries", None)
- args.pop("self", None)
- args.pop("params", None)
- args.pop("__class__", None)
- if max_retries is not None and isinstance(max_retries, str):
- max_retries = int(max_retries) # cast to int
- # We need to keep max_retries in args since it's a parameter of GenericLiteLLMParams
- args[
- "max_retries"
- ] = max_retries # Put max_retries back in args after popping it
- super().__init__(**args, **params)
+ @model_validator(mode="before")
+ @classmethod
+ def preprocess_input_data(cls, data: Any) -> Any:
+ """
+ Pre-process input data before validation:
+ 1. Filter out reserved Python keywords ('self', 'params', '__class__') to prevent
+ 'got multiple values for argument' errors when user data contains these keys.
+ 2. Convert max_retries from string to int if needed.
+ """
+ if isinstance(data, dict):
+ filtered = {k: v for k, v in data.items() if k not in _RESERVED_INIT_KEYS}
+ if "max_retries" in filtered and isinstance(filtered["max_retries"], str):
+ filtered["max_retries"] = int(filtered["max_retries"])
+ return filtered
+ return data
def __contains__(self, key):
# Define custom behavior for the 'in' operator
@@ -311,46 +258,6 @@ class LiteLLM_Params(GenericLiteLLMParams):
model: str
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
- def __init__(
- self,
- model: str,
- custom_llm_provider: Optional[str] = None,
- max_retries: Optional[Union[int, str]] = None,
- tpm: Optional[int] = None,
- rpm: Optional[int] = None,
- api_key: Optional[str] = None,
- api_base: Optional[str] = None,
- api_version: Optional[str] = None,
- timeout: Optional[Union[float, str]] = None, # if str, pass in as os.environ/
- stream_timeout: Optional[Union[float, str]] = (
- None # timeout when making stream=True calls, if str, pass in as os.environ/
- ),
- organization: Optional[str] = None, # for openai orgs
- ## VERTEX AI ##
- vertex_project: Optional[str] = None,
- vertex_location: Optional[str] = None,
- ## AWS BEDROCK / SAGEMAKER ##
- aws_access_key_id: Optional[str] = None,
- aws_secret_access_key: Optional[str] = None,
- aws_region_name: Optional[str] = None,
- # OpenAI / Azure Whisper
- # set a max-size of file that can be passed to litellm proxy
- max_file_size_mb: Optional[float] = None,
- # will use deployment on pass-through endpoints if True
- use_in_pass_through: Optional[bool] = False,
- use_litellm_proxy: Optional[bool] = False,
- **params,
- ):
- args = locals()
- args.pop("max_retries", None)
- args.pop("self", None)
- args.pop("params", None)
- args.pop("__class__", None)
- if max_retries is not None and isinstance(max_retries, str):
- max_retries = int(max_retries) # cast to int
- args["max_retries"] = max_retries
- super().__init__(**{**args, **params})
-
def __contains__(self, key):
# Define custom behavior for the 'in' operator
return hasattr(self, key)
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index 8ae0cf28925..b5d5c06924d 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -3177,6 +3177,7 @@ class LlmProviders(str, Enum):
TOPAZ = "topaz"
SAP_GENERATIVE_AI_HUB = "sap"
ASSEMBLYAI = "assemblyai"
+ CHARITY_ENGINE = "charity_engine"
GITHUB_COPILOT = "github_copilot"
SNOWFLAKE = "snowflake"
GRADIENT_AI = "gradient_ai"
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 177a2bf52e0..194af4895fe 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -4207,6 +4207,41 @@
"supports_tool_choice": true,
"supports_vision": true
},
+ "azure/gpt-5.3-chat": {
+ "cache_read_input_token_cost": 1.75e-07,
+ "cache_read_input_token_cost_priority": 3.5e-07,
+ "input_cost_per_token": 1.75e-06,
+ "input_cost_per_token_priority": 3.5e-06,
+ "litellm_provider": "azure",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 16384,
+ "max_tokens": 16384,
+ "mode": "chat",
+ "output_cost_per_token": 1.4e-05,
+ "output_cost_per_token_priority": 2.8e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
"azure/gpt-5.3-codex": {
"cache_read_input_token_cost": 1.75e-07,
"input_cost_per_token": 1.75e-06,
@@ -4299,6 +4334,160 @@
"supports_vision": true,
"supports_web_search": true
},
+ "azure/gpt-5.4": {
+ "cache_read_input_token_cost": 2.5e-07,
+ "cache_read_input_token_cost_above_272k_tokens": 5e-07,
+ "cache_read_input_token_cost_priority": 5e-07,
+ "cache_read_input_token_cost_above_272k_tokens_priority": 1e-06,
+ "input_cost_per_token": 2.5e-06,
+ "input_cost_per_token_above_272k_tokens": 5e-06,
+ "input_cost_per_token_priority": 5e-06,
+ "input_cost_per_token_above_272k_tokens_priority": 1e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "chat",
+ "output_cost_per_token": 1.5e-05,
+ "output_cost_per_token_above_272k_tokens": 2.25e-05,
+ "output_cost_per_token_priority": 3e-05,
+ "output_cost_per_token_above_272k_tokens_priority": 4.5e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
+ "azure/gpt-5.4-2026-03-05": {
+ "cache_read_input_token_cost": 2.5e-07,
+ "cache_read_input_token_cost_above_272k_tokens": 5e-07,
+ "cache_read_input_token_cost_priority": 5e-07,
+ "cache_read_input_token_cost_above_272k_tokens_priority": 1e-06,
+ "input_cost_per_token": 2.5e-06,
+ "input_cost_per_token_above_272k_tokens": 5e-06,
+ "input_cost_per_token_priority": 5e-06,
+ "input_cost_per_token_above_272k_tokens_priority": 1e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "chat",
+ "output_cost_per_token": 1.5e-05,
+ "output_cost_per_token_above_272k_tokens": 2.25e-05,
+ "output_cost_per_token_priority": 3e-05,
+ "output_cost_per_token_above_272k_tokens_priority": 4.5e-05,
+ "supported_endpoints": [
+ "/v1/chat/completions",
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": true,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_service_tier": true,
+ "supports_vision": true
+ },
+ "azure/gpt-5.4-pro": {
+ "cache_read_input_token_cost": 3e-06,
+ "cache_read_input_token_cost_above_272k_tokens": 6e-06,
+ "input_cost_per_token": 3e-05,
+ "input_cost_per_token_above_272k_tokens": 6e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "responses",
+ "output_cost_per_token": 0.00018,
+ "output_cost_per_token_above_272k_tokens": 0.00027,
+ "supported_endpoints": [
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": false,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
+ "azure/gpt-5.4-pro-2026-03-05": {
+ "cache_read_input_token_cost": 3e-06,
+ "cache_read_input_token_cost_above_272k_tokens": 6e-06,
+ "input_cost_per_token": 3e-05,
+ "input_cost_per_token_above_272k_tokens": 6e-05,
+ "litellm_provider": "azure",
+ "max_input_tokens": 1050000,
+ "max_output_tokens": 128000,
+ "max_tokens": 128000,
+ "mode": "responses",
+ "output_cost_per_token": 0.00018,
+ "output_cost_per_token_above_272k_tokens": 0.00027,
+ "supported_endpoints": [
+ "/v1/batch",
+ "/v1/responses"
+ ],
+ "supported_modalities": [
+ "text",
+ "image"
+ ],
+ "supported_output_modalities": [
+ "text"
+ ],
+ "supports_function_calling": true,
+ "supports_native_streaming": true,
+ "supports_parallel_function_calling": true,
+ "supports_pdf_input": true,
+ "supports_prompt_caching": true,
+ "supports_reasoning": true,
+ "supports_response_schema": false,
+ "supports_system_messages": true,
+ "supports_tool_choice": true,
+ "supports_vision": true,
+ "supports_web_search": true
+ },
"azure/gpt-image-1": {
"cache_read_input_image_token_cost": 2.5e-06,
"cache_read_input_token_cost": 1.25e-06,
diff --git a/tests/test_litellm/llms/openai_like/test_charity_engine.py b/tests/test_litellm/llms/openai_like/test_charity_engine.py
new file mode 100644
index 00000000000..5d6a751b624
--- /dev/null
+++ b/tests/test_litellm/llms/openai_like/test_charity_engine.py
@@ -0,0 +1,101 @@
+"""
+Tests for Charity Engine provider configuration and integration.
+"""
+
+import os
+import sys
+
+try:
+ import pytest
+except ImportError:
+ pytest = None
+
+# Add workspace to path
+workspace_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
+sys.path.insert(0, workspace_path)
+
+import litellm
+
+
+class TestCharityEngineProviderConfig:
+ """Test Charity Engine provider configuration"""
+
+ def test_charity_engine_in_provider_list(self):
+ """Test that charity_engine is in the provider list"""
+ from litellm import LlmProviders
+
+ assert hasattr(LlmProviders, "CHARITY_ENGINE")
+ assert LlmProviders.CHARITY_ENGINE.value == "charity_engine"
+ assert "charity_engine" in litellm.provider_list
+
+ def test_charity_engine_json_config_exists(self):
+ """Test that charity_engine is configured in providers.json"""
+ from litellm.llms.openai_like.json_loader import JSONProviderRegistry
+
+ assert JSONProviderRegistry.exists("charity_engine")
+
+ charity_engine = JSONProviderRegistry.get("charity_engine")
+ assert charity_engine is not None
+ assert charity_engine.base_url == "https://api.charityengine.services/remotejobs/v2/inference"
+ assert charity_engine.api_key_env == "CHARITY_ENGINE_API_KEY"
+ assert charity_engine.param_mappings.get("max_completion_tokens") == "max_tokens"
+
+ def test_charity_engine_provider_resolution(self):
+ """Test that provider resolution finds charity_engine"""
+ from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
+
+ model, provider, api_key, api_base = get_llm_provider(
+ model="charity_engine/gemma3:270m",
+ custom_llm_provider=None,
+ api_base=None,
+ api_key=None,
+ )
+
+ assert model == "gemma3:270m"
+ assert provider == "charity_engine"
+ assert api_base == "https://api.charityengine.services/remotejobs/v2/inference"
+
+ def test_charity_engine_router_config(self):
+ """Test that charity_engine can be used in Router configuration"""
+ from litellm import Router
+
+ router = Router(
+ model_list=[
+ {
+ "model_name": "gemma3-270m",
+ "litellm_params": {
+ "model": "charity_engine/gemma3:270m",
+ "api_key": "test-key",
+ },
+ }
+ ]
+ )
+
+ assert len(router.model_list) == 1
+ assert router.model_list[0]["model_name"] == "gemma3-270m"
+
+
+if __name__ == "__main__":
+ print("Testing Charity Engine Provider...")
+
+ test_config = TestCharityEngineProviderConfig()
+
+ print("\n1. Testing provider in list...")
+ test_config.test_charity_engine_in_provider_list()
+ print(" ✓ charity_engine in provider list")
+
+ print("\n2. Testing JSON config...")
+ test_config.test_charity_engine_json_config_exists()
+ print(" ✓ charity_engine JSON config loaded")
+
+ print("\n3. Testing provider resolution...")
+ test_config.test_charity_engine_provider_resolution()
+ print(" ✓ Provider resolution works")
+
+ print("\n4. Testing router configuration...")
+ test_config.test_charity_engine_router_config()
+ print(" ✓ Router configuration works")
+
+ print("\n" + "=" * 50)
+ print("✓ All configuration tests passed!")
+ print("=" * 50)
diff --git a/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py b/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py
index c2527d8fbdc..3c1fa52cb09 100644
--- a/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py
+++ b/tests/test_litellm/llms/snowflake/chat/test_snowflake_chat_transformation.py
@@ -105,7 +105,10 @@ class TestSnowflakeToolTransformation:
def test_transform_request_with_string_tool_choice(self):
"""
- Test that string tool_choice values pass through unchanged.
+ Test that string tool_choice values are transformed to Snowflake object format.
+
+ Snowflake requires tool_choice to be an object, not a string.
+ Ref: https://docs.snowflake.com/en/developer-guide/snowflake-rest-api/reference/cortex-inference#post--api-v2-cortex-inference-complete-req-body-schema
"""
config = SnowflakeConfig()
@@ -120,7 +123,8 @@ class TestSnowflakeToolTransformation:
headers={},
)
- assert transformed_request["tool_choice"] == value
+ # Snowflake requires object format: {"type": "auto"} not string "auto"
+ assert transformed_request["tool_choice"] == {"type": value}
def test_transform_response_with_tool_calls(self):
"""
diff --git a/tests/test_litellm/test_litellm_params_reserved_keys.py b/tests/test_litellm/test_litellm_params_reserved_keys.py
new file mode 100644
index 00000000000..f49651bd814
--- /dev/null
+++ b/tests/test_litellm/test_litellm_params_reserved_keys.py
@@ -0,0 +1,92 @@
+"""
+Test that LiteLLM_Params and GenericLiteLLMParams handle reserved keys gracefully.
+
+This test verifies the fix for the bug where passing a dict containing 'self',
+'params', or '__class__' keys to LiteLLM_Params() would cause:
+ TypeError: LiteLLM_Params.__init__() got multiple values for argument 'self'
+"""
+
+import pytest
+
+from litellm.types.router import GenericLiteLLMParams, LiteLLM_Params
+
+
+class TestLiteLLMParamsReservedKeys:
+ """Test that reserved keys in input data are filtered out gracefully."""
+
+ def test_litellm_params_with_self_key(self):
+ """Test LiteLLM_Params handles 'self' key in input dict."""
+ params_dict = {"model": "gpt-4", "self": "some_value", "api_key": "test-key"}
+ params = LiteLLM_Params(**params_dict)
+ assert params.model == "gpt-4"
+ assert params.api_key == "test-key"
+ assert not hasattr(params, "self") or params.get("self") is None
+
+ def test_litellm_params_with_params_key(self):
+ """Test LiteLLM_Params handles 'params' key in input dict."""
+ params_dict = {"model": "gpt-4", "params": "bad_value"}
+ params = LiteLLM_Params(**params_dict)
+ assert params.model == "gpt-4"
+
+ def test_litellm_params_with_class_key(self):
+ """Test LiteLLM_Params handles '__class__' key in input dict."""
+ params_dict = {"model": "gpt-4", "__class__": "bad_value"}
+ params = LiteLLM_Params(**params_dict)
+ assert params.model == "gpt-4"
+
+ def test_generic_litellm_params_with_self_key(self):
+ """Test GenericLiteLLMParams handles 'self' key in input dict."""
+ params_dict = {"self": "some_value", "api_key": "test-key"}
+ params = GenericLiteLLMParams(**params_dict)
+ assert params.api_key == "test-key"
+
+ def test_generic_litellm_params_with_params_key(self):
+ """Test GenericLiteLLMParams handles 'params' key in input dict."""
+ params_dict = {"params": "bad_value", "api_key": "test-key"}
+ params = GenericLiteLLMParams(**params_dict)
+ assert params.api_key == "test-key"
+
+ def test_generic_litellm_params_with_class_key(self):
+ """Test GenericLiteLLMParams handles '__class__' key in input dict."""
+ params_dict = {"__class__": "bad_value", "api_key": "test-key"}
+ params = GenericLiteLLMParams(**params_dict)
+ assert params.api_key == "test-key"
+
+ def test_max_retries_string_conversion(self):
+ """Test that max_retries is converted from string to int."""
+ params = LiteLLM_Params(model="gpt-4", max_retries="5")
+ assert params.max_retries == 5
+ assert isinstance(params.max_retries, int)
+
+ def test_extra_fields_preserved(self):
+ """Test that extra fields are preserved when reserved keys are filtered."""
+ params_dict = {
+ "model": "gpt-4",
+ "self": "ignored",
+ "custom_field": "custom_value",
+ }
+ params = LiteLLM_Params(**params_dict)
+ assert params.model == "gpt-4"
+ assert params.custom_field == "custom_value"
+
+ def test_normal_instantiation_still_works(self):
+ """Test that normal instantiation without reserved keys works."""
+ params = LiteLLM_Params(
+ model="gpt-4", api_key="test-key", custom_llm_provider="openai"
+ )
+ assert params.model == "gpt-4"
+ assert params.api_key == "test-key"
+ assert params.custom_llm_provider == "openai"
+
+ def test_multiple_reserved_keys(self):
+ """Test filtering multiple reserved keys at once."""
+ params_dict = {
+ "model": "gpt-4",
+ "self": "value1",
+ "params": "value2",
+ "__class__": "value3",
+ "api_key": "test-key",
+ }
+ params = LiteLLM_Params(**params_dict)
+ assert params.model == "gpt-4"
+ assert params.api_key == "test-key"