From dfc68dbe936761b99c7d8cc6235734ae8e4cb7bc Mon Sep 17 00:00:00 2001 From: stimQQ Date: Thu, 5 Nov 2026 18:24:51 +0900 Subject: [PATCH 1/2] feat: add apimodels.app as an OpenAI-compatible provider Registers apimodels as a JSON-configured OpenAI-compatible provider with APIMODELS_API_KEY and APIMODELS_API_BASE, defaulting to https://api.apimodels.app/v1. Adds it to LlmProviders, the openai-compatible provider and endpoint lists, the Admin UI Add Model form, the endpoint support matrix, and cost map rows for apimodels.app chat models. This is the earlier branch replayed onto current main as one commit. Co-Authored-By: Claude Opus 5.5 --- litellm/constants.py | 2 + litellm/llms/openai_like/providers.json | 5 + ...odel_prices_and_context_window_backup.json | 640 ++++++++++++++++++ .../provider_endpoints_support_backup.json | 18 + .../provider_create_fields.json | 28 + litellm/types/utils.py | 1 + model_prices_and_context_window.json | 640 ++++++++++++++++++ provider_endpoints_support.json | 18 + .../openai_like/test_apimodels_provider.py | 275 ++++++++ 9 files changed, 1627 insertions(+) create mode 100644 tests/unit/llms/openai_like/test_apimodels_provider.py diff --git a/litellm/constants.py b/litellm/constants.py index 50e090eabaf..479831707a9 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1094,6 +1094,7 @@ openai_compatible_endpoints: Final[list[str]] = [ "https://api.prisminference.com/v1", "https://api.reka.ai/v1", "https://inference.runanywhere.ai/v1", + "https://api.apimodels.app/v1", "https://gigachat.devices.sberbank.ru/api/v1", "https://api.openinfer.ai/v1", "https://vanchin.streamlake.ai/api/gateway/v1/endpoints", @@ -1182,6 +1183,7 @@ openai_compatible_providers: Final[list[str]] = [ "reka", "streamlake", "wally", + "apimodels", ] OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers)) diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index f937e4d2f75..85bb42a53b3 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -314,5 +314,10 @@ "supports_function_calling": true, "supports_reasoning": true } + }, + "apimodels": { + "base_url": "https://api.apimodels.app/v1", + "api_key_env": "APIMODELS_API_KEY", + "api_base_env": "APIMODELS_API_BASE" } } diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 76fd85d001b..3b26902d510 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -73944,6 +73944,646 @@ "supports_tool_choice": true, "supports_vision": true }, + "apimodels/claude-fable-5-1": { + "cache_creation_input_token_cost": 5.778e-06, + "cache_read_input_token_cost": 2.2e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://apimodels.app/models/claude-fable-5-1", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-fable-5": { + "cache_creation_input_token_cost": 8.824e-06, + "cache_read_input_token_cost": 8.82e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://apimodels.app/models/claude-fable-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-5-5": { + "cache_creation_input_token_cost": 3e-06, + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 2.4e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.2e-05, + "source": "https://apimodels.app/models/claude-opus-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-5": { + "cache_creation_input_token_cost": 4.891e-06, + "cache_read_input_token_cost": 3.91e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://apimodels.app/models/claude-opus-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-8": { + "cache_creation_input_token_cost": 1.765e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.3e-05, + "source": "https://apimodels.app/models/claude-opus-4-8", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-7": { + "cache_creation_input_token_cost": 4.595e-06, + "cache_read_input_token_cost": 3.676e-07, + "input_cost_per_token": 3.676e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.8382e-05, + "source": "https://apimodels.app/models/claude-opus-4-7", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-6": { + "cache_creation_input_token_cost": 2.206e-06, + "cache_read_input_token_cost": 1.765e-07, + "input_cost_per_token": 1.765e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8.824e-06, + "source": "https://apimodels.app/models/claude-opus-4-6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-5-20251101": { + "cache_creation_input_token_cost": 2.206e-06, + "cache_read_input_token_cost": 1.765e-07, + "input_cost_per_token": 1.765e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 8.824e-06, + "source": "https://apimodels.app/models/claude-opus-4-5-20251101", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-5-5": { + "cache_creation_input_token_cost": 1.5e-06, + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 1.2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://apimodels.app/models/claude-sonnet-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-5": { + "cache_creation_input_token_cost": 1.4e-06, + "cache_read_input_token_cost": 1e-07, + "input_cost_per_token": 1.6e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8e-06, + "source": "https://apimodels.app/models/claude-sonnet-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-4-6": { + "cache_creation_input_token_cost": 1.324e-06, + "cache_read_input_token_cost": 1.059e-07, + "input_cost_per_token": 1.059e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5.295e-06, + "source": "https://apimodels.app/models/claude-sonnet-4-6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-haiku-5-5": { + "cache_creation_input_token_cost": 1.125e-07, + "cache_creation_input_token_cost_above_100k_tokens": 5.625e-07, + "cache_read_input_token_cost": 9e-09, + "cache_read_input_token_cost_above_100k_tokens": 4.5e-08, + "input_cost_per_token": 9e-08, + "input_cost_per_token_above_100k_tokens": 4.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.5e-07, + "output_cost_per_token_above_100k_tokens": 2.25e-06, + "source": "https://apimodels.app/models/claude-haiku-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-haiku-4-5-20251001": { + "cache_creation_input_token_cost": 4.41e-07, + "cache_read_input_token_cost": 3.53e-08, + "input_cost_per_token": 3.53e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 1.765e-06, + "source": "https://apimodels.app/models/claude-haiku-4-5-20251001", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.8-flash": { + "cache_read_input_token_cost": 1.72e-07, + "input_cost_per_token": 4.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.25e-06, + "source": "https://apimodels.app/models/gemini-3.8-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.6-flash": { + "cache_read_input_token_cost": 6.62e-08, + "input_cost_per_token": 6.62e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.302e-06, + "source": "https://apimodels.app/models/gemini-3.6-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.5-flash": { + "cache_read_input_token_cost": 6.62e-08, + "input_cost_per_token": 6.62e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.971e-06, + "source": "https://apimodels.app/models/gemini-3.5-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.1-flash-lite": { + "cache_read_input_token_cost": 2.5e-08, + "input_cost_per_token": 3.75e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.25e-06, + "source": "https://apimodels.app/models/gemini-3.1-flash-lite", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-astra": { + "cache_read_input_token_cost": 3.4e-07, + "cache_read_input_token_cost_above_272k_tokens": 6.8e-07, + "input_cost_per_token": 3.4e-06, + "input_cost_per_token_above_272k_tokens": 6.8e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.7e-05, + "output_cost_per_token_above_272k_tokens": 2.55e-05, + "source": "https://apimodels.app/models/gpt-6-astra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6.1-sol": { + "cache_read_input_token_cost": 5e-08, + "cache_read_input_token_cost_above_272k_tokens": 1e-07, + "input_cost_per_token": 1e-06, + "input_cost_per_token_above_272k_tokens": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5e-06, + "output_cost_per_token_above_272k_tokens": 7.5e-06, + "source": "https://apimodels.app/models/gpt-6.1-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-sol": { + "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_272k_tokens": 2e-07, + "input_cost_per_token": 1e-06, + "input_cost_per_token_above_272k_tokens": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5e-06, + "output_cost_per_token_above_272k_tokens": 7.5e-06, + "source": "https://apimodels.app/models/gpt-6-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-luna": { + "cache_read_input_token_cost": 9e-09, + "cache_read_input_token_cost_above_272k_tokens": 1.8e-08, + "input_cost_per_token": 9e-08, + "input_cost_per_token_above_272k_tokens": 1.8e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.5e-07, + "output_cost_per_token_above_272k_tokens": 6.75e-07, + "source": "https://apimodels.app/models/gpt-6-luna", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-sol": { + "cache_read_input_token_cost": 1.32e-07, + "cache_read_input_token_cost_above_272k_tokens": 2.64e-07, + "input_cost_per_token": 1.324e-06, + "input_cost_per_token_above_272k_tokens": 2.648e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6.618e-06, + "output_cost_per_token_above_272k_tokens": 9.927e-06, + "source": "https://apimodels.app/models/gpt-5-6-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-terra": { + "cache_read_input_token_cost": 5.5e-08, + "cache_read_input_token_cost_above_272k_tokens": 1.1e-07, + "input_cost_per_token": 5.51e-07, + "input_cost_per_token_above_272k_tokens": 1.102e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3.309e-06, + "output_cost_per_token_above_272k_tokens": 4.9635e-06, + "source": "https://apimodels.app/models/gpt-5-6-terra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-luna": { + "cache_read_input_token_cost": 1.8e-08, + "cache_read_input_token_cost_above_272k_tokens": 3.6e-08, + "input_cost_per_token": 1.8e-07, + "input_cost_per_token_above_272k_tokens": 3.6e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 9.6e-07, + "output_cost_per_token_above_272k_tokens": 1.44e-06, + "source": "https://apimodels.app/models/gpt-5-6-luna", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5-5": { + "cache_read_input_token_cost": 5e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1050000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.8e-05, + "source": "https://apimodels.app/models/gpt-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5-4": { + "cache_read_input_token_cost": 2.5e-07, + "input_cost_per_token": 1.8e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1050000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.08e-05, + "source": "https://apimodels.app/models/gpt-5-4", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/grok-4.6": { + "cache_read_input_token_cost": 3.75e-07, + "input_cost_per_token": 1.5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 500000, + "max_output_tokens": 500000, + "max_tokens": 500000, + "mode": "chat", + "output_cost_per_token": 4.5e-06, + "source": "https://apimodels.app/models/grok-4.6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/grok-4.5": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 1.275e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 500000, + "max_output_tokens": 500000, + "max_tokens": 500000, + "mode": "chat", + "output_cost_per_token": 4.25e-06, + "source": "https://apimodels.app/models/grok-4.5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/glm-5.3": { + "cache_read_input_token_cost": 2.47e-07, + "input_cost_per_token": 1.33e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.18e-06, + "source": "https://apimodels.app/models/glm-5.3", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/glm-5.2": { + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.26e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3.96e-06, + "source": "https://apimodels.app/models/glm-5.2", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/deepseek-v4.1-flash": { + "cache_read_input_token_cost": 5.4e-09, + "input_cost_per_token": 2.7e-07, + "litellm_provider": "apimodels", + "mode": "chat", + "off_peak_pricing": { + "cache_read_input_token_cost": 2.7e-09, + "input_cost_per_token": 1.35e-07, + "output_cost_per_token": 5.4e-07, + "windows": [ + { + "hours_utc": [ + "00:00-01:00", + "04:00-06:00", + "10:00-00:00" + ], + "weekdays": [ + 1, + 2, + 3, + 4, + 5 + ] + }, + { + "hours_utc": "00:00-00:00", + "weekdays": [ + 6, + 7 + ] + } + ] + }, + "output_cost_per_token": 1.08e-06, + "source": "https://apimodels.app/models/deepseek-v4.1-flash" + }, + "apimodels/deepseek-v4-flash": { + "cache_read_input_token_cost": 5.4e-09, + "input_cost_per_token": 2.7e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 393216, + "max_tokens": 393216, + "mode": "chat", + "off_peak_pricing": { + "cache_read_input_token_cost": 2.7e-09, + "input_cost_per_token": 1.35e-07, + "output_cost_per_token": 5.4e-07, + "windows": [ + { + "hours_utc": [ + "00:00-01:00", + "04:00-06:00", + "10:00-00:00" + ], + "weekdays": [ + 1, + 2, + 3, + 4, + 5 + ] + }, + { + "hours_utc": "00:00-00:00", + "weekdays": [ + 6, + 7 + ] + } + ] + }, + "output_cost_per_token": 1.08e-06, + "source": "https://apimodels.app/models/deepseek-v4-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.8-max": { + "cache_read_input_token_cost": 2.5e-07, + "input_cost_per_token": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://apimodels.app/models/qwen3.8-max", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.8-flash": { + "cache_read_input_token_cost": 1.6e-08, + "input_cost_per_token": 1.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 4.7e-07, + "source": "https://apimodels.app/models/qwen3.8-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.7-max": { + "cache_read_input_token_cost": 4.5e-07, + "input_cost_per_token": 2.25e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 6.75e-06, + "source": "https://apimodels.app/models/qwen3.7-max", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.7-plus": { + "cache_read_input_token_cost": 7.2e-08, + "input_cost_per_token": 3.6e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.44e-06, + "source": "https://apimodels.app/models/qwen3.7-plus", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "tiered_pricing": [ + { + "cache_read_input_token_cost": 7.2e-08, + "input_cost_per_token": 3.6e-07, + "output_cost_per_token": 1.44e-06, + "range": [ + 0, + 262144 + ] + }, + { + "cache_read_input_token_cost": 2.16e-07, + "input_cost_per_token": 1.08e-06, + "output_cost_per_token": 4.32e-06, + "range": [ + 262144, + 1000000 + ] + } + ] + }, "bespoke/nimble-latest": { "input_cost_per_token": 0.0, "litellm_provider": "bespoke", diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index 00fee0a0d5a..35635eb23df 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -347,6 +347,24 @@ "generateContent": true } }, + "apimodels": { + "display_name": "apimodels.app (`apimodels`)", + "url": "https://docs.litellm.ai/docs/providers/apimodels", + "endpoints": { + "chat_completions": true, + "messages": true, + "responses": true, + "embeddings": false, + "image_generations": false, + "audio_transcriptions": false, + "audio_speech": false, + "moderations": false, + "batches": false, + "rerank": false, + "a2a": false, + "interactions": false + } + }, "assemblyai": { "display_name": "AssemblyAI (`assemblyai`)", "url": "https://docs.litellm.ai/docs/pass_through/assembly_ai", diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index 5ded2fa5f5e..7ece7d0cb75 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -3743,6 +3743,34 @@ ], "default_model_placeholder": "inferenceapis/deepseek-ai/DeepSeek-V4-Flash" }, + { + "provider": "APIMODELS", + "provider_display_name": "apimodels.app", + "litellm_provider": "apimodels", + "credential_fields": [ + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://api.apimodels.app/v1", + "tooltip": null, + "required": false, + "field_type": "text", + "options": null, + "default_value": null + }, + { + "key": "api_key", + "label": "API Key", + "placeholder": null, + "tooltip": null, + "required": true, + "field_type": "password", + "options": null, + "default_value": null + } + ], + "default_model_placeholder": "apimodels/claude-opus-5-5" + }, { "provider": "StreamLake", "provider_display_name": "StreamLake", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index ba29a67a36c..9205418eb11 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4781,6 +4781,7 @@ class LlmProviders(str, Enum): REKA = "reka" STREAMLAKE = "streamlake" WALLY = "wally" + APIMODELS = "apimodels" LITELLM_AGENT = "litellm_agent" CURSOR = "cursor" BEDROCK_MANTLE = "bedrock_mantle" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 76fd85d001b..3b26902d510 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -73944,6 +73944,646 @@ "supports_tool_choice": true, "supports_vision": true }, + "apimodels/claude-fable-5-1": { + "cache_creation_input_token_cost": 5.778e-06, + "cache_read_input_token_cost": 2.2e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://apimodels.app/models/claude-fable-5-1", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-fable-5": { + "cache_creation_input_token_cost": 8.824e-06, + "cache_read_input_token_cost": 8.82e-07, + "input_cost_per_token": 5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://apimodels.app/models/claude-fable-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-5-5": { + "cache_creation_input_token_cost": 3e-06, + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 2.4e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.2e-05, + "source": "https://apimodels.app/models/claude-opus-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-5": { + "cache_creation_input_token_cost": 4.891e-06, + "cache_read_input_token_cost": 3.91e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://apimodels.app/models/claude-opus-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-8": { + "cache_creation_input_token_cost": 1.765e-06, + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.3e-05, + "source": "https://apimodels.app/models/claude-opus-4-8", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-7": { + "cache_creation_input_token_cost": 4.595e-06, + "cache_read_input_token_cost": 3.676e-07, + "input_cost_per_token": 3.676e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.8382e-05, + "source": "https://apimodels.app/models/claude-opus-4-7", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-6": { + "cache_creation_input_token_cost": 2.206e-06, + "cache_read_input_token_cost": 1.765e-07, + "input_cost_per_token": 1.765e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8.824e-06, + "source": "https://apimodels.app/models/claude-opus-4-6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-opus-4-5-20251101": { + "cache_creation_input_token_cost": 2.206e-06, + "cache_read_input_token_cost": 1.765e-07, + "input_cost_per_token": 1.765e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 8.824e-06, + "source": "https://apimodels.app/models/claude-opus-4-5-20251101", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-5-5": { + "cache_creation_input_token_cost": 1.5e-06, + "cache_read_input_token_cost": 1.2e-07, + "input_cost_per_token": 1.2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://apimodels.app/models/claude-sonnet-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-5": { + "cache_creation_input_token_cost": 1.4e-06, + "cache_read_input_token_cost": 1e-07, + "input_cost_per_token": 1.6e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 8e-06, + "source": "https://apimodels.app/models/claude-sonnet-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-sonnet-4-6": { + "cache_creation_input_token_cost": 1.324e-06, + "cache_read_input_token_cost": 1.059e-07, + "input_cost_per_token": 1.059e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5.295e-06, + "source": "https://apimodels.app/models/claude-sonnet-4-6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-haiku-5-5": { + "cache_creation_input_token_cost": 1.125e-07, + "cache_creation_input_token_cost_above_100k_tokens": 5.625e-07, + "cache_read_input_token_cost": 9e-09, + "cache_read_input_token_cost_above_100k_tokens": 4.5e-08, + "input_cost_per_token": 9e-08, + "input_cost_per_token_above_100k_tokens": 4.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.5e-07, + "output_cost_per_token_above_100k_tokens": 2.25e-06, + "source": "https://apimodels.app/models/claude-haiku-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/claude-haiku-4-5-20251001": { + "cache_creation_input_token_cost": 4.41e-07, + "cache_read_input_token_cost": 3.53e-08, + "input_cost_per_token": 3.53e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "max_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 1.765e-06, + "source": "https://apimodels.app/models/claude-haiku-4-5-20251001", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.8-flash": { + "cache_read_input_token_cost": 1.72e-07, + "input_cost_per_token": 4.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.25e-06, + "source": "https://apimodels.app/models/gemini-3.8-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.6-flash": { + "cache_read_input_token_cost": 6.62e-08, + "input_cost_per_token": 6.62e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.302e-06, + "source": "https://apimodels.app/models/gemini-3.6-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.5-flash": { + "cache_read_input_token_cost": 6.62e-08, + "input_cost_per_token": 6.62e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.971e-06, + "source": "https://apimodels.app/models/gemini-3.5-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gemini-3.1-flash-lite": { + "cache_read_input_token_cost": 2.5e-08, + "input_cost_per_token": 3.75e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.25e-06, + "source": "https://apimodels.app/models/gemini-3.1-flash-lite", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-astra": { + "cache_read_input_token_cost": 3.4e-07, + "cache_read_input_token_cost_above_272k_tokens": 6.8e-07, + "input_cost_per_token": 3.4e-06, + "input_cost_per_token_above_272k_tokens": 6.8e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.7e-05, + "output_cost_per_token_above_272k_tokens": 2.55e-05, + "source": "https://apimodels.app/models/gpt-6-astra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6.1-sol": { + "cache_read_input_token_cost": 5e-08, + "cache_read_input_token_cost_above_272k_tokens": 1e-07, + "input_cost_per_token": 1e-06, + "input_cost_per_token_above_272k_tokens": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5e-06, + "output_cost_per_token_above_272k_tokens": 7.5e-06, + "source": "https://apimodels.app/models/gpt-6.1-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-sol": { + "cache_read_input_token_cost": 1e-07, + "cache_read_input_token_cost_above_272k_tokens": 2e-07, + "input_cost_per_token": 1e-06, + "input_cost_per_token_above_272k_tokens": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 5e-06, + "output_cost_per_token_above_272k_tokens": 7.5e-06, + "source": "https://apimodels.app/models/gpt-6-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-6-luna": { + "cache_read_input_token_cost": 9e-09, + "cache_read_input_token_cost_above_272k_tokens": 1.8e-08, + "input_cost_per_token": 9e-08, + "input_cost_per_token_above_272k_tokens": 1.8e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.5e-07, + "output_cost_per_token_above_272k_tokens": 6.75e-07, + "source": "https://apimodels.app/models/gpt-6-luna", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-sol": { + "cache_read_input_token_cost": 1.32e-07, + "cache_read_input_token_cost_above_272k_tokens": 2.64e-07, + "input_cost_per_token": 1.324e-06, + "input_cost_per_token_above_272k_tokens": 2.648e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 6.618e-06, + "output_cost_per_token_above_272k_tokens": 9.927e-06, + "source": "https://apimodels.app/models/gpt-5-6-sol", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-terra": { + "cache_read_input_token_cost": 5.5e-08, + "cache_read_input_token_cost_above_272k_tokens": 1.1e-07, + "input_cost_per_token": 5.51e-07, + "input_cost_per_token_above_272k_tokens": 1.102e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3.309e-06, + "output_cost_per_token_above_272k_tokens": 4.9635e-06, + "source": "https://apimodels.app/models/gpt-5-6-terra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5.6-luna": { + "cache_read_input_token_cost": 1.8e-08, + "cache_read_input_token_cost_above_272k_tokens": 3.6e-08, + "input_cost_per_token": 1.8e-07, + "input_cost_per_token_above_272k_tokens": 3.6e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 9.6e-07, + "output_cost_per_token_above_272k_tokens": 1.44e-06, + "source": "https://apimodels.app/models/gpt-5-6-luna", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5-5": { + "cache_read_input_token_cost": 5e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1050000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.8e-05, + "source": "https://apimodels.app/models/gpt-5-5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/gpt-5-4": { + "cache_read_input_token_cost": 2.5e-07, + "input_cost_per_token": 1.8e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1050000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.08e-05, + "source": "https://apimodels.app/models/gpt-5-4", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/grok-4.6": { + "cache_read_input_token_cost": 3.75e-07, + "input_cost_per_token": 1.5e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 500000, + "max_output_tokens": 500000, + "max_tokens": 500000, + "mode": "chat", + "output_cost_per_token": 4.5e-06, + "source": "https://apimodels.app/models/grok-4.6", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/grok-4.5": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 1.275e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 500000, + "max_output_tokens": 500000, + "max_tokens": 500000, + "mode": "chat", + "output_cost_per_token": 4.25e-06, + "source": "https://apimodels.app/models/grok-4.5", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, + "apimodels/glm-5.3": { + "cache_read_input_token_cost": 2.47e-07, + "input_cost_per_token": 1.33e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 4.18e-06, + "source": "https://apimodels.app/models/glm-5.3", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/glm-5.2": { + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.26e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 128000, + "max_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 3.96e-06, + "source": "https://apimodels.app/models/glm-5.2", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/deepseek-v4.1-flash": { + "cache_read_input_token_cost": 5.4e-09, + "input_cost_per_token": 2.7e-07, + "litellm_provider": "apimodels", + "mode": "chat", + "off_peak_pricing": { + "cache_read_input_token_cost": 2.7e-09, + "input_cost_per_token": 1.35e-07, + "output_cost_per_token": 5.4e-07, + "windows": [ + { + "hours_utc": [ + "00:00-01:00", + "04:00-06:00", + "10:00-00:00" + ], + "weekdays": [ + 1, + 2, + 3, + 4, + 5 + ] + }, + { + "hours_utc": "00:00-00:00", + "weekdays": [ + 6, + 7 + ] + } + ] + }, + "output_cost_per_token": 1.08e-06, + "source": "https://apimodels.app/models/deepseek-v4.1-flash" + }, + "apimodels/deepseek-v4-flash": { + "cache_read_input_token_cost": 5.4e-09, + "input_cost_per_token": 2.7e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 1000000, + "max_output_tokens": 393216, + "max_tokens": 393216, + "mode": "chat", + "off_peak_pricing": { + "cache_read_input_token_cost": 2.7e-09, + "input_cost_per_token": 1.35e-07, + "output_cost_per_token": 5.4e-07, + "windows": [ + { + "hours_utc": [ + "00:00-01:00", + "04:00-06:00", + "10:00-00:00" + ], + "weekdays": [ + 1, + 2, + 3, + 4, + 5 + ] + }, + { + "hours_utc": "00:00-00:00", + "weekdays": [ + 6, + 7 + ] + } + ] + }, + "output_cost_per_token": 1.08e-06, + "source": "https://apimodels.app/models/deepseek-v4-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.8-max": { + "cache_read_input_token_cost": 2.5e-07, + "input_cost_per_token": 2e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://apimodels.app/models/qwen3.8-max", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.8-flash": { + "cache_read_input_token_cost": 1.6e-08, + "input_cost_per_token": 1.5e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 4.7e-07, + "source": "https://apimodels.app/models/qwen3.8-flash", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.7-max": { + "cache_read_input_token_cost": 4.5e-07, + "input_cost_per_token": 2.25e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 6.75e-06, + "source": "https://apimodels.app/models/qwen3.7-max", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true + }, + "apimodels/qwen3.7-plus": { + "cache_read_input_token_cost": 7.2e-08, + "input_cost_per_token": 3.6e-07, + "litellm_provider": "apimodels", + "max_input_tokens": 991808, + "max_output_tokens": 65536, + "max_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.44e-06, + "source": "https://apimodels.app/models/qwen3.7-plus", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "tiered_pricing": [ + { + "cache_read_input_token_cost": 7.2e-08, + "input_cost_per_token": 3.6e-07, + "output_cost_per_token": 1.44e-06, + "range": [ + 0, + 262144 + ] + }, + { + "cache_read_input_token_cost": 2.16e-07, + "input_cost_per_token": 1.08e-06, + "output_cost_per_token": 4.32e-06, + "range": [ + 262144, + 1000000 + ] + } + ] + }, "bespoke/nimble-latest": { "input_cost_per_token": 0.0, "litellm_provider": "bespoke", diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 00fee0a0d5a..d7a65ba89c7 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -321,6 +321,24 @@ "generateContent": false } }, + "apimodels": { + "display_name": "apimodels.app (`apimodels`)", + "url": "https://docs.litellm.ai/docs/providers/apimodels", + "endpoints": { + "chat_completions": true, + "messages": true, + "responses": true, + "embeddings": false, + "image_generations": false, + "audio_transcriptions": false, + "audio_speech": false, + "moderations": false, + "batches": false, + "rerank": false, + "a2a": false, + "interactions": false + } + }, "aihubmix": { "display_name": "AIHubMix (`aihubmix`)", "url": "https://docs.litellm.ai/docs/providers/aihubmix", diff --git a/tests/unit/llms/openai_like/test_apimodels_provider.py b/tests/unit/llms/openai_like/test_apimodels_provider.py new file mode 100644 index 00000000000..b52bf676897 --- /dev/null +++ b/tests/unit/llms/openai_like/test_apimodels_provider.py @@ -0,0 +1,275 @@ +import json +from pathlib import Path +from typing import Final + +import pytest +import respx + +import litellm +from litellm.caching.llm_caching_handler import LLMClientCache + + +def _chat_completion(model: str) -> dict: + return { + "id": "chatcmpl_apimodels", + "object": "chat.completion", + "created": 1_790_000_000, + "model": model, + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "Hello from APIMODELS"}, + "finish_reason": "stop", + } + ], + "usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7}, + } + + +def test_apimodels_is_a_registered_provider(): + assert litellm.LlmProviders.APIMODELS.value == "apimodels" + assert "apimodels" in litellm.provider_list + assert "apimodels" in litellm.constants.openai_compatible_providers + + +def test_apimodels_provider_resolution(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-test-key") + monkeypatch.delenv("APIMODELS_API_BASE", raising=False) + + model, provider, api_key, api_base = get_llm_provider( + model="apimodels/gpt-5.6-luna", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert model == "gpt-5.6-luna" + assert provider == "apimodels" + assert api_key == "apimodels-test-key" + assert api_base == "https://api.apimodels.app/v1" + + +def test_apimodels_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") + monkeypatch.setenv("APIMODELS_API_BASE", "https://apimodels.env.example/v1") + + _, provider, api_key, api_base = get_llm_provider( + model="apimodels/gpt-5.6-luna", + custom_llm_provider=None, + api_base="https://apimodels.internal.example/v1", + api_key="apimodels-explicit-key", + ) + + assert provider == "apimodels" + assert api_key == "apimodels-explicit-key" + assert api_base == "https://apimodels.internal.example/v1" + + +def test_apimodels_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") + monkeypatch.setenv("APIMODELS_API_BASE", "https://apimodels.env.example/v1") + + _, provider, _, api_base = get_llm_provider( + model="apimodels/gpt-5.6-luna", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert provider == "apimodels" + assert api_base == "https://apimodels.env.example/v1" + + +def test_apimodels_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") + + model, provider, api_key, api_base = get_llm_provider( + model="gpt-5.6-luna", + custom_llm_provider=None, + api_base="https://api.apimodels.app/v1", + api_key=None, + ) + + assert model == "gpt-5.6-luna" + assert provider == "apimodels" + assert api_key == "apimodels-env-key" + assert api_base == "https://api.apimodels.app/v1" + + +def test_apimodels_is_available_in_add_model_form(): + fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json" + providers = json.loads(fields_path.read_text()) + apimodels = next(provider for provider in providers if provider["litellm_provider"] == "apimodels") + + assert apimodels["provider"] == "APIMODELS" + assert apimodels["provider_display_name"] == "apimodels.app" + assert apimodels["default_model_placeholder"] == "apimodels/claude-opus-5-5" + assert {field["key"]: field["required"] for field in apimodels["credential_fields"]} == { + "api_base": False, + "api_key": True, + } + + +def test_apimodels_supported_endpoints(): + expected: Final = { + "chat_completions": True, + "messages": True, + "responses": True, + "embeddings": False, + "image_generations": False, + "audio_transcriptions": False, + "audio_speech": False, + "moderations": False, + "batches": False, + "rerank": False, + "a2a": False, + "interactions": False, + } + backup_path = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json" + root_path = Path(litellm.__file__).parent.parent / "provider_endpoints_support.json" + + assert json.loads(backup_path.read_text())["providers"]["apimodels"]["endpoints"] == expected + assert json.loads(root_path.read_text())["providers"]["apimodels"]["endpoints"] == expected + + +def test_apimodels_chat_completion_request_uses_env_api_key(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") + monkeypatch.delenv("APIMODELS_API_BASE", raising=False) + with respx.mock() as upstream: + route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( + 200, json=_chat_completion("gpt-5.6-luna") + ) + response: Final = litellm.completion( + model="apimodels/gpt-5.6-luna", + messages=[{"role": "user", "content": "Say hello"}], + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert str(request.url) == "https://api.apimodels.app/v1/chat/completions" + assert request.headers["authorization"] == "Bearer apimodels-env-key" + assert body["model"] == "gpt-5.6-luna" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert response.choices[0].message.content == "Hello from APIMODELS" + + +def test_apimodels_chat_completion_request_honours_api_base_override(): + with respx.mock() as upstream: + route: Final = upstream.post("https://apimodels.internal.example/v1/chat/completions").respond( + 200, json=_chat_completion("gpt-5.6-luna") + ) + response: Final = litellm.completion( + model="apimodels/gpt-5.6-luna", + messages=[{"role": "user", "content": "Say hello"}], + api_base="https://apimodels.internal.example/v1", + api_key="apimodels-explicit-key", + ) + + request: Final = route.calls.last.request + assert route.call_count == 1 + assert str(request.url) == "https://apimodels.internal.example/v1/chat/completions" + assert request.headers["authorization"] == "Bearer apimodels-explicit-key" + assert response.choices[0].message.content == "Hello from APIMODELS" + + +def test_apimodels_responses_request_is_bridged_to_chat_completions(): + with respx.mock() as upstream: + route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( + 200, json=_chat_completion("claude-opus-5-5") + ) + response: Final = litellm.responses( + model="apimodels/claude-opus-5-5", + input="Say hello", + api_key="apimodels-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer apimodels-test-key" + assert body["model"] == "claude-opus-5-5" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert response.output[0].content[0].text == "Hello from APIMODELS" + + +@pytest.mark.asyncio +async def test_apimodels_anthropic_messages_request_is_bridged_to_chat_completions(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) + monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) + with respx.mock() as upstream: + route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( + 200, json=_chat_completion("gpt-5.6-luna") + ) + response: Final = await litellm.anthropic.messages.acreate( + model="apimodels/gpt-5.6-luna", + messages=[{"role": "user", "content": "Say hello"}], + max_tokens=32, + api_key="apimodels-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer apimodels-test-key" + assert body["model"] == "gpt-5.6-luna" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert body["max_tokens"] == 32 + assert response["content"][0]["text"] == "Hello from APIMODELS" + + +def _completion_with_usage(model: str, usage: dict[str, object]) -> litellm.ModelResponse: + body: Final = {**_chat_completion(model), "usage": usage} + with respx.mock() as upstream: + upstream.post("https://api.apimodels.app/v1/chat/completions").respond(200, json=body) + return litellm.completion( + model=f"apimodels/{model}", + messages=[{"role": "user", "content": "Say hello"}], + api_key="apimodels-test-key", + ) + + +def test_apimodels_chat_completion_cost_bills_cached_tokens_at_cache_read_rate(): + row: Final = litellm.model_cost["apimodels/gpt-6-sol"] + response: Final = _completion_with_usage( + "gpt-6-sol", + { + "prompt_tokens": 1000, + "completion_tokens": 20, + "total_tokens": 1020, + "prompt_tokens_details": {"cached_tokens": 800}, + }, + ) + + assert row["cache_read_input_token_cost"] < row["input_cost_per_token"] + assert litellm.completion_cost(completion_response=response, model="apimodels/gpt-6-sol") == pytest.approx( + 200 * row["input_cost_per_token"] + 800 * row["cache_read_input_token_cost"] + 20 * row["output_cost_per_token"] + ) + + +def test_apimodels_prompt_over_272k_bills_the_whole_request_at_the_long_context_rates(): + row: Final = litellm.model_cost["apimodels/gpt-6-sol"] + response: Final = _completion_with_usage( + "gpt-6-sol", + { + "prompt_tokens": 300_000, + "completion_tokens": 20, + "total_tokens": 300_020, + "prompt_tokens_details": {"cached_tokens": 100_000}, + }, + ) + + assert row["input_cost_per_token_above_272k_tokens"] > row["input_cost_per_token"] + assert litellm.completion_cost(completion_response=response, model="apimodels/gpt-6-sol") == pytest.approx( + 200_000 * row["input_cost_per_token_above_272k_tokens"] + + 100_000 * row["cache_read_input_token_cost_above_272k_tokens"] + + 20 * row["output_cost_per_token_above_272k_tokens"] + ) From 13d6d2accb120b8628d9a43f70431254d2f9d960 Mon Sep 17 00:00:00 2001 From: stimQQ Date: Thu, 5 Nov 2026 18:40:09 +0900 Subject: [PATCH 2/2] feat(apimodels): list models per provider, regenerate endpoint flags, resync prices - litellm/__init__.py: add apimodels_models, so apimodels/* wildcards and models_by_provider return the apimodels rows, as for other JSON providers - provider_endpoints_support.json and its backup: regenerated with scripts/generate_provider_endpoints_support.py for the current schema - cost map: drop the retired max_tokens field; add gpt-6.1-terra and claude-sonnet-4-5-20250929; the other 36 rows were checked against apimodels.app list prices and are unchanged - tests: per-row cost and capability checks, apimodels/* wildcard expansion, backup mirror, and the half-rate DeepSeek off-peak windows Co-Authored-By: Claude Opus 5.5 --- litellm/__init__.py | 5 + ...odel_prices_and_context_window_backup.json | 67 ++++--- .../provider_endpoints_support_backup.json | 44 +++-- model_prices_and_context_window.json | 67 ++++--- provider_endpoints_support.json | 18 +- .../openai_like/test_apimodels_provider.py | 176 +++++++++++++----- 6 files changed, 238 insertions(+), 139 deletions(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 8e5dd68a186..fd1338c5cfe 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -689,6 +689,7 @@ openinfer_models: Final[Set[str]] = set() kyma_models: Final[set[str]] = set() # mutable-ok: populated when the shared model catalog loads streamlake_models: Final[Set[str]] = set() wally_models: Final[Set[str]] = set() +apimodels_models: Final[Set[str]] = set() zerogpu_models: Final[Set[str]] = set() v0_models: Set = set() morph_models: Set = set() @@ -987,6 +988,8 @@ def _populate_provider_model_sets(model_cost_map: Mapping[str, Mapping[str, obje streamlake_models.add(key) elif value.get("litellm_provider") == "wally": wally_models.add(key) + elif value.get("litellm_provider") == "apimodels": + apimodels_models.add(key) elif value.get("litellm_provider") == "zerogpu": zerogpu_models.add(key) elif value.get("litellm_provider") == "v0": @@ -1169,6 +1172,7 @@ model_list = list( | kyma_models | streamlake_models | wally_models + | apimodels_models | zerogpu_models | v0_models | morph_models @@ -1303,6 +1307,7 @@ def _build_models_by_provider() -> dict: "kyma": kyma_models, "streamlake": streamlake_models, "wally": wally_models, + "apimodels": apimodels_models, "zerogpu": zerogpu_models, "v0": v0_models, "morph": morph_models, diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 3b26902d510..70fa1a0115b 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -73951,7 +73951,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 2.5e-05, "source": "https://apimodels.app/models/claude-fable-5-1", @@ -73967,7 +73966,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 2.5e-05, "source": "https://apimodels.app/models/claude-fable-5", @@ -73983,7 +73981,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.2e-05, "source": "https://apimodels.app/models/claude-opus-5-5", @@ -73999,7 +73996,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.5e-05, "source": "https://apimodels.app/models/claude-opus-5", @@ -74015,7 +74011,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.3e-05, "source": "https://apimodels.app/models/claude-opus-4-8", @@ -74031,7 +74026,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.8382e-05, "source": "https://apimodels.app/models/claude-opus-4-7", @@ -74047,7 +74041,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 8.824e-06, "source": "https://apimodels.app/models/claude-opus-4-6", @@ -74063,7 +74056,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 200000, "max_output_tokens": 64000, - "max_tokens": 64000, "mode": "chat", "output_cost_per_token": 8.824e-06, "source": "https://apimodels.app/models/claude-opus-4-5-20251101", @@ -74079,7 +74071,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 6e-06, "source": "https://apimodels.app/models/claude-sonnet-5-5", @@ -74095,7 +74086,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 8e-06, "source": "https://apimodels.app/models/claude-sonnet-5", @@ -74111,7 +74101,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5.295e-06, "source": "https://apimodels.app/models/claude-sonnet-4-6", @@ -74120,6 +74109,21 @@ "supports_reasoning": true, "supports_vision": true }, + "apimodels/claude-sonnet-4-5-20250929": { + "cache_creation_input_token_cost": 1.324e-06, + "cache_read_input_token_cost": 1.059e-07, + "input_cost_per_token": 1.059e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 5.295e-06, + "source": "https://apimodels.app/models/claude-sonnet-4-5-20250929", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, "apimodels/claude-haiku-5-5": { "cache_creation_input_token_cost": 1.125e-07, "cache_creation_input_token_cost_above_100k_tokens": 5.625e-07, @@ -74130,7 +74134,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.5e-07, "output_cost_per_token_above_100k_tokens": 2.25e-06, @@ -74147,7 +74150,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 200000, "max_output_tokens": 64000, - "max_tokens": 64000, "mode": "chat", "output_cost_per_token": 1.765e-06, "source": "https://apimodels.app/models/claude-haiku-4-5-20251001", @@ -74162,7 +74164,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 2.25e-06, "source": "https://apimodels.app/models/gemini-3.8-flash", @@ -74177,7 +74178,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 3.302e-06, "source": "https://apimodels.app/models/gemini-3.6-flash", @@ -74192,7 +74192,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 3.971e-06, "source": "https://apimodels.app/models/gemini-3.5-flash", @@ -74207,7 +74206,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 2.25e-06, "source": "https://apimodels.app/models/gemini-3.1-flash-lite", @@ -74224,7 +74222,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.7e-05, "output_cost_per_token_above_272k_tokens": 2.55e-05, @@ -74242,7 +74239,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5e-06, "output_cost_per_token_above_272k_tokens": 7.5e-06, @@ -74252,6 +74248,23 @@ "supports_reasoning": true, "supports_vision": true }, + "apimodels/gpt-6.1-terra": { + "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost_above_272k_tokens": 5e-08, + "input_cost_per_token": 5e-07, + "input_cost_per_token_above_272k_tokens": 1e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "output_cost_per_token_above_272k_tokens": 3.75e-06, + "source": "https://apimodels.app/models/gpt-6.1-terra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, "apimodels/gpt-6-sol": { "cache_read_input_token_cost": 1e-07, "cache_read_input_token_cost_above_272k_tokens": 2e-07, @@ -74260,7 +74273,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5e-06, "output_cost_per_token_above_272k_tokens": 7.5e-06, @@ -74278,7 +74290,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.5e-07, "output_cost_per_token_above_272k_tokens": 6.75e-07, @@ -74296,7 +74307,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 6.618e-06, "output_cost_per_token_above_272k_tokens": 9.927e-06, @@ -74314,7 +74324,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 3.309e-06, "output_cost_per_token_above_272k_tokens": 4.9635e-06, @@ -74332,7 +74341,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 9.6e-07, "output_cost_per_token_above_272k_tokens": 1.44e-06, @@ -74348,7 +74356,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1050000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.8e-05, "source": "https://apimodels.app/models/gpt-5-5", @@ -74363,7 +74370,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1050000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.08e-05, "source": "https://apimodels.app/models/gpt-5-4", @@ -74378,7 +74384,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 500000, "max_output_tokens": 500000, - "max_tokens": 500000, "mode": "chat", "output_cost_per_token": 4.5e-06, "source": "https://apimodels.app/models/grok-4.6", @@ -74393,7 +74398,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 500000, "max_output_tokens": 500000, - "max_tokens": 500000, "mode": "chat", "output_cost_per_token": 4.25e-06, "source": "https://apimodels.app/models/grok-4.5", @@ -74408,7 +74412,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.18e-06, "source": "https://apimodels.app/models/glm-5.3", @@ -74422,7 +74425,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 3.96e-06, "source": "https://apimodels.app/models/glm-5.2", @@ -74472,7 +74474,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 393216, - "max_tokens": 393216, "mode": "chat", "off_peak_pricing": { "cache_read_input_token_cost": 2.7e-09, @@ -74514,7 +74515,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 131072, - "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 6e-06, "source": "https://apimodels.app/models/qwen3.8-max", @@ -74528,7 +74528,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 131072, - "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 4.7e-07, "source": "https://apimodels.app/models/qwen3.8-flash", @@ -74542,7 +74541,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 6.75e-06, "source": "https://apimodels.app/models/qwen3.7-max", @@ -74556,7 +74554,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 1.44e-06, "source": "https://apimodels.app/models/qwen3.7-plus", diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index 35635eb23df..a80568dc9d3 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -321,6 +321,32 @@ "generateContent": false } }, + "apimodels": { + "display_name": "apimodels.app (`apimodels`)", + "url": "https://docs.litellm.ai/docs/providers/apimodels", + "endpoints": { + "chat_completions": true, + "responses": true, + "text_completion": true, + "embeddings": false, + "image_generations": false, + "image_edits": false, + "audio_transcriptions": false, + "audio_speech": false, + "rerank": false, + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": true, + "interactions": true, + "systemone": false, + "a2a": true, + "generateContent": true + } + }, "aihubmix": { "display_name": "AIHubMix (`aihubmix`)", "url": "https://docs.litellm.ai/docs/providers/aihubmix", @@ -347,24 +373,6 @@ "generateContent": true } }, - "apimodels": { - "display_name": "apimodels.app (`apimodels`)", - "url": "https://docs.litellm.ai/docs/providers/apimodels", - "endpoints": { - "chat_completions": true, - "messages": true, - "responses": true, - "embeddings": false, - "image_generations": false, - "audio_transcriptions": false, - "audio_speech": false, - "moderations": false, - "batches": false, - "rerank": false, - "a2a": false, - "interactions": false - } - }, "assemblyai": { "display_name": "AssemblyAI (`assemblyai`)", "url": "https://docs.litellm.ai/docs/pass_through/assembly_ai", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 3b26902d510..70fa1a0115b 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -73951,7 +73951,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 2.5e-05, "source": "https://apimodels.app/models/claude-fable-5-1", @@ -73967,7 +73966,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 2.5e-05, "source": "https://apimodels.app/models/claude-fable-5", @@ -73983,7 +73981,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.2e-05, "source": "https://apimodels.app/models/claude-opus-5-5", @@ -73999,7 +73996,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.5e-05, "source": "https://apimodels.app/models/claude-opus-5", @@ -74015,7 +74011,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.3e-05, "source": "https://apimodels.app/models/claude-opus-4-8", @@ -74031,7 +74026,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.8382e-05, "source": "https://apimodels.app/models/claude-opus-4-7", @@ -74047,7 +74041,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 8.824e-06, "source": "https://apimodels.app/models/claude-opus-4-6", @@ -74063,7 +74056,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 200000, "max_output_tokens": 64000, - "max_tokens": 64000, "mode": "chat", "output_cost_per_token": 8.824e-06, "source": "https://apimodels.app/models/claude-opus-4-5-20251101", @@ -74079,7 +74071,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 6e-06, "source": "https://apimodels.app/models/claude-sonnet-5-5", @@ -74095,7 +74086,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 8e-06, "source": "https://apimodels.app/models/claude-sonnet-5", @@ -74111,7 +74101,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5.295e-06, "source": "https://apimodels.app/models/claude-sonnet-4-6", @@ -74120,6 +74109,21 @@ "supports_reasoning": true, "supports_vision": true }, + "apimodels/claude-sonnet-4-5-20250929": { + "cache_creation_input_token_cost": 1.324e-06, + "cache_read_input_token_cost": 1.059e-07, + "input_cost_per_token": 1.059e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "mode": "chat", + "output_cost_per_token": 5.295e-06, + "source": "https://apimodels.app/models/claude-sonnet-4-5-20250929", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, "apimodels/claude-haiku-5-5": { "cache_creation_input_token_cost": 1.125e-07, "cache_creation_input_token_cost_above_100k_tokens": 5.625e-07, @@ -74130,7 +74134,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.5e-07, "output_cost_per_token_above_100k_tokens": 2.25e-06, @@ -74147,7 +74150,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 200000, "max_output_tokens": 64000, - "max_tokens": 64000, "mode": "chat", "output_cost_per_token": 1.765e-06, "source": "https://apimodels.app/models/claude-haiku-4-5-20251001", @@ -74162,7 +74164,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 2.25e-06, "source": "https://apimodels.app/models/gemini-3.8-flash", @@ -74177,7 +74178,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 3.302e-06, "source": "https://apimodels.app/models/gemini-3.6-flash", @@ -74192,7 +74192,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 3.971e-06, "source": "https://apimodels.app/models/gemini-3.5-flash", @@ -74207,7 +74206,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1048576, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 2.25e-06, "source": "https://apimodels.app/models/gemini-3.1-flash-lite", @@ -74224,7 +74222,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.7e-05, "output_cost_per_token_above_272k_tokens": 2.55e-05, @@ -74242,7 +74239,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5e-06, "output_cost_per_token_above_272k_tokens": 7.5e-06, @@ -74252,6 +74248,23 @@ "supports_reasoning": true, "supports_vision": true }, + "apimodels/gpt-6.1-terra": { + "cache_read_input_token_cost": 2.5e-08, + "cache_read_input_token_cost_above_272k_tokens": 5e-08, + "input_cost_per_token": 5e-07, + "input_cost_per_token_above_272k_tokens": 1e-06, + "litellm_provider": "apimodels", + "max_input_tokens": 922000, + "max_output_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "output_cost_per_token_above_272k_tokens": 3.75e-06, + "source": "https://apimodels.app/models/gpt-6.1-terra", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_vision": true + }, "apimodels/gpt-6-sol": { "cache_read_input_token_cost": 1e-07, "cache_read_input_token_cost_above_272k_tokens": 2e-07, @@ -74260,7 +74273,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 5e-06, "output_cost_per_token_above_272k_tokens": 7.5e-06, @@ -74278,7 +74290,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.5e-07, "output_cost_per_token_above_272k_tokens": 6.75e-07, @@ -74296,7 +74307,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 6.618e-06, "output_cost_per_token_above_272k_tokens": 9.927e-06, @@ -74314,7 +74324,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 3.309e-06, "output_cost_per_token_above_272k_tokens": 4.9635e-06, @@ -74332,7 +74341,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 922000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 9.6e-07, "output_cost_per_token_above_272k_tokens": 1.44e-06, @@ -74348,7 +74356,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1050000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.8e-05, "source": "https://apimodels.app/models/gpt-5-5", @@ -74363,7 +74370,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1050000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 1.08e-05, "source": "https://apimodels.app/models/gpt-5-4", @@ -74378,7 +74384,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 500000, "max_output_tokens": 500000, - "max_tokens": 500000, "mode": "chat", "output_cost_per_token": 4.5e-06, "source": "https://apimodels.app/models/grok-4.6", @@ -74393,7 +74398,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 500000, "max_output_tokens": 500000, - "max_tokens": 500000, "mode": "chat", "output_cost_per_token": 4.25e-06, "source": "https://apimodels.app/models/grok-4.5", @@ -74408,7 +74412,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 4.18e-06, "source": "https://apimodels.app/models/glm-5.3", @@ -74422,7 +74425,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 128000, - "max_tokens": 128000, "mode": "chat", "output_cost_per_token": 3.96e-06, "source": "https://apimodels.app/models/glm-5.2", @@ -74472,7 +74474,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 1000000, "max_output_tokens": 393216, - "max_tokens": 393216, "mode": "chat", "off_peak_pricing": { "cache_read_input_token_cost": 2.7e-09, @@ -74514,7 +74515,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 131072, - "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 6e-06, "source": "https://apimodels.app/models/qwen3.8-max", @@ -74528,7 +74528,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 131072, - "max_tokens": 131072, "mode": "chat", "output_cost_per_token": 4.7e-07, "source": "https://apimodels.app/models/qwen3.8-flash", @@ -74542,7 +74541,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 6.75e-06, "source": "https://apimodels.app/models/qwen3.7-max", @@ -74556,7 +74554,6 @@ "litellm_provider": "apimodels", "max_input_tokens": 991808, "max_output_tokens": 65536, - "max_tokens": 65536, "mode": "chat", "output_cost_per_token": 1.44e-06, "source": "https://apimodels.app/models/qwen3.7-plus", diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index d7a65ba89c7..a80568dc9d3 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -326,17 +326,25 @@ "url": "https://docs.litellm.ai/docs/providers/apimodels", "endpoints": { "chat_completions": true, - "messages": true, "responses": true, + "text_completion": true, "embeddings": false, "image_generations": false, + "image_edits": false, "audio_transcriptions": false, "audio_speech": false, - "moderations": false, - "batches": false, "rerank": false, - "a2a": false, - "interactions": false + "ocr": false, + "search": false, + "moderations": false, + "realtime": false, + "video_generations": false, + "batches": false, + "messages": true, + "interactions": true, + "systemone": false, + "a2a": true, + "generateContent": true } }, "aihubmix": { diff --git a/tests/unit/llms/openai_like/test_apimodels_provider.py b/tests/unit/llms/openai_like/test_apimodels_provider.py index b52bf676897..4cef2eeaa88 100644 --- a/tests/unit/llms/openai_like/test_apimodels_provider.py +++ b/tests/unit/llms/openai_like/test_apimodels_provider.py @@ -1,4 +1,5 @@ import json +from datetime import datetime, timezone from pathlib import Path from typing import Final @@ -6,7 +7,30 @@ import pytest import respx import litellm +from litellm._internal_context import pinned_billing_time from litellm.caching.llm_caching_handler import LLMClientCache +from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + +_DEFAULT_API_BASE: Final = "https://api.apimodels.app/v1" +_CHAT_COMPLETIONS_URL: Final = f"{_DEFAULT_API_BASE}/chat/completions" +_EXPECTED_ENDPOINTS: Final = { + "chat_completions": True, + "messages": True, + "responses": True, + "embeddings": False, + "image_generations": False, + "audio_transcriptions": False, + "audio_speech": False, + "moderations": False, + "batches": False, + "rerank": False, +} +# A Tuesday inside the DeepSeek weekday peak hours, and two moments outside them. +_WEEKDAY_PEAK: Final = datetime(2026, 11, 3, 2, 0, tzinfo=timezone.utc) +_WEEKDAY_OFF_PEAK: Final = datetime(2026, 11, 3, 12, 0, tzinfo=timezone.utc) +_WEEKEND: Final = datetime(2026, 11, 7, 2, 0, tzinfo=timezone.utc) +APIMODELS_MODELS: Final = tuple(sorted(name for name in litellm.model_cost if name.startswith("apimodels/"))) +OFF_PEAK_MODELS: Final = tuple(name for name in APIMODELS_MODELS if "off_peak_pricing" in litellm.model_cost[name]) def _chat_completion(model: str) -> dict: @@ -30,11 +54,10 @@ def test_apimodels_is_a_registered_provider(): assert litellm.LlmProviders.APIMODELS.value == "apimodels" assert "apimodels" in litellm.provider_list assert "apimodels" in litellm.constants.openai_compatible_providers + assert _DEFAULT_API_BASE in litellm.constants.openai_compatible_endpoints def test_apimodels_provider_resolution(monkeypatch: pytest.MonkeyPatch): - from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider - monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-test-key") monkeypatch.delenv("APIMODELS_API_BASE", raising=False) @@ -48,12 +71,10 @@ def test_apimodels_provider_resolution(monkeypatch: pytest.MonkeyPatch): assert model == "gpt-5.6-luna" assert provider == "apimodels" assert api_key == "apimodels-test-key" - assert api_base == "https://api.apimodels.app/v1" + assert api_base == _DEFAULT_API_BASE def test_apimodels_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch): - from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider - monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") monkeypatch.setenv("APIMODELS_API_BASE", "https://apimodels.env.example/v1") @@ -70,8 +91,6 @@ def test_apimodels_provider_keeps_explicit_credentials(monkeypatch: pytest.Monke def test_apimodels_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch): - from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider - monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") monkeypatch.setenv("APIMODELS_API_BASE", "https://apimodels.env.example/v1") @@ -87,31 +106,90 @@ def test_apimodels_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatc def test_apimodels_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch): - from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider - monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") model, provider, api_key, api_base = get_llm_provider( model="gpt-5.6-luna", custom_llm_provider=None, - api_base="https://api.apimodels.app/v1", + api_base=_DEFAULT_API_BASE, api_key=None, ) assert model == "gpt-5.6-luna" assert provider == "apimodels" assert api_key == "apimodels-env-key" - assert api_base == "https://api.apimodels.app/v1" + assert api_base == _DEFAULT_API_BASE + + +@pytest.mark.parametrize("model", APIMODELS_MODELS) +def test_apimodels_model_cost_and_capabilities(model: str): + from litellm.cost_calculator import cost_per_token + from litellm.utils import supports_function_calling, supports_prompt_caching, supports_reasoning, supports_vision + + entry: Final = litellm.model_cost[model] + with pinned_billing_time(_WEEKDAY_PEAK): + prompt_cost, completion_cost = cost_per_token( + model=model, + prompt_tokens=1_000, + completion_tokens=1_000, + custom_llm_provider="apimodels", + ) + cached_prompt_cost, _ = cost_per_token( + model=model, + prompt_tokens=1_000, + completion_tokens=0, + cache_read_input_tokens=1_000, + custom_llm_provider="apimodels", + ) + model_info: Final = litellm.get_model_info(model) + + assert entry["source"].startswith("https://apimodels.app/models/") + assert entry["cache_read_input_token_cost"] < entry["input_cost_per_token"] + assert prompt_cost == pytest.approx(entry["input_cost_per_token"] * 1_000) + assert completion_cost == pytest.approx(entry["output_cost_per_token"] * 1_000) + assert cached_prompt_cost == pytest.approx(entry["cache_read_input_token_cost"] * 1_000) + assert model_info["litellm_provider"] == "apimodels" + assert "max_tokens" not in entry + assert model_info["max_tokens"] == entry.get("max_output_tokens") + declared_capabilities: Final = { + flag: check(model) + for flag, check in ( + ("supports_function_calling", supports_function_calling), + ("supports_reasoning", supports_reasoning), + ("supports_prompt_caching", supports_prompt_caching), + ("supports_vision", supports_vision), + ) + if flag in entry + } + assert declared_capabilities == {flag: entry[flag] for flag in declared_capabilities} + + +@pytest.mark.usefixtures("local_model_cost_map") +def test_apimodels_wildcard_expands_to_every_apimodels_row(): + from litellm.proxy.auth.model_checks import get_known_models_from_wildcard + + assert set(get_known_models_from_wildcard("apimodels/*")) == set(APIMODELS_MODELS) + + +def test_apimodels_backup_registry_mirrors_cost_map(): + package_root: Final = Path(litellm.__file__).parent + cost_map: Final = json.loads((package_root.parent / "model_prices_and_context_window.json").read_text()) + backup: Final = json.loads((package_root / "model_prices_and_context_window_backup.json").read_text()) + apimodels_entries: Final = {name: entry for name, entry in cost_map.items() if name.startswith("apimodels/")} + + assert apimodels_entries + assert tuple(sorted(apimodels_entries)) == APIMODELS_MODELS + assert apimodels_entries == {name: backup[name] for name in apimodels_entries} def test_apimodels_is_available_in_add_model_form(): - fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json" - providers = json.loads(fields_path.read_text()) - apimodels = next(provider for provider in providers if provider["litellm_provider"] == "apimodels") + fields_path: Final = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json" + providers: Final = json.loads(fields_path.read_text()) + apimodels: Final = next(provider for provider in providers if provider["litellm_provider"] == "apimodels") assert apimodels["provider"] == "APIMODELS" assert apimodels["provider_display_name"] == "apimodels.app" - assert apimodels["default_model_placeholder"] == "apimodels/claude-opus-5-5" + assert apimodels["default_model_placeholder"] in APIMODELS_MODELS assert {field["key"]: field["required"] for field in apimodels["credential_fields"]} == { "api_base": False, "api_key": True, @@ -119,34 +197,21 @@ def test_apimodels_is_available_in_add_model_form(): def test_apimodels_supported_endpoints(): - expected: Final = { - "chat_completions": True, - "messages": True, - "responses": True, - "embeddings": False, - "image_generations": False, - "audio_transcriptions": False, - "audio_speech": False, - "moderations": False, - "batches": False, - "rerank": False, - "a2a": False, - "interactions": False, - } - backup_path = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json" - root_path = Path(litellm.__file__).parent.parent / "provider_endpoints_support.json" + backup_path: Final = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json" + root_path: Final = Path(litellm.__file__).parent.parent / "provider_endpoints_support.json" - assert json.loads(backup_path.read_text())["providers"]["apimodels"]["endpoints"] == expected - assert json.loads(root_path.read_text())["providers"]["apimodels"]["endpoints"] == expected + backup: Final = json.loads(backup_path.read_text())["providers"]["apimodels"]["endpoints"] + root: Final = json.loads(root_path.read_text())["providers"]["apimodels"]["endpoints"] + + assert backup == root + assert {endpoint: root[endpoint] for endpoint in _EXPECTED_ENDPOINTS} == _EXPECTED_ENDPOINTS def test_apimodels_chat_completion_request_uses_env_api_key(monkeypatch: pytest.MonkeyPatch): monkeypatch.setenv("APIMODELS_API_KEY", "apimodels-env-key") monkeypatch.delenv("APIMODELS_API_BASE", raising=False) with respx.mock() as upstream: - route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( - 200, json=_chat_completion("gpt-5.6-luna") - ) + route: Final = upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=_chat_completion("gpt-5.6-luna")) response: Final = litellm.completion( model="apimodels/gpt-5.6-luna", messages=[{"role": "user", "content": "Say hello"}], @@ -155,7 +220,7 @@ def test_apimodels_chat_completion_request_uses_env_api_key(monkeypatch: pytest. request: Final = route.calls.last.request body: Final = json.loads(request.content) assert route.call_count == 1 - assert str(request.url) == "https://api.apimodels.app/v1/chat/completions" + assert str(request.url) == _CHAT_COMPLETIONS_URL assert request.headers["authorization"] == "Bearer apimodels-env-key" assert body["model"] == "gpt-5.6-luna" assert body["messages"] == [{"role": "user", "content": "Say hello"}] @@ -183,9 +248,7 @@ def test_apimodels_chat_completion_request_honours_api_base_override(): def test_apimodels_responses_request_is_bridged_to_chat_completions(): with respx.mock() as upstream: - route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( - 200, json=_chat_completion("claude-opus-5-5") - ) + route: Final = upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=_chat_completion("claude-opus-5-5")) response: Final = litellm.responses( model="apimodels/claude-opus-5-5", input="Say hello", @@ -198,7 +261,8 @@ def test_apimodels_responses_request_is_bridged_to_chat_completions(): assert request.headers["authorization"] == "Bearer apimodels-test-key" assert body["model"] == "claude-opus-5-5" assert body["messages"] == [{"role": "user", "content": "Say hello"}] - assert response.output[0].content[0].text == "Hello from APIMODELS" + message_items: Final = [item for item in response.output if item.type == "message"] + assert message_items[0].content[0].text == "Hello from APIMODELS" @pytest.mark.asyncio @@ -206,9 +270,7 @@ async def test_apimodels_anthropic_messages_request_is_bridged_to_chat_completio monkeypatch.setattr(litellm, "disable_aiohttp_transport", True) monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache()) with respx.mock() as upstream: - route: Final = upstream.post("https://api.apimodels.app/v1/chat/completions").respond( - 200, json=_chat_completion("gpt-5.6-luna") - ) + route: Final = upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=_chat_completion("gpt-5.6-luna")) response: Final = await litellm.anthropic.messages.acreate( model="apimodels/gpt-5.6-luna", messages=[{"role": "user", "content": "Say hello"}], @@ -223,13 +285,13 @@ async def test_apimodels_anthropic_messages_request_is_bridged_to_chat_completio assert body["model"] == "gpt-5.6-luna" assert body["messages"] == [{"role": "user", "content": "Say hello"}] assert body["max_tokens"] == 32 - assert response["content"][0]["text"] == "Hello from APIMODELS" + assert any(block.get("text") == "Hello from APIMODELS" for block in response["content"]) def _completion_with_usage(model: str, usage: dict[str, object]) -> litellm.ModelResponse: body: Final = {**_chat_completion(model), "usage": usage} with respx.mock() as upstream: - upstream.post("https://api.apimodels.app/v1/chat/completions").respond(200, json=body) + upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=body) return litellm.completion( model=f"apimodels/{model}", messages=[{"role": "user", "content": "Say hello"}], @@ -273,3 +335,25 @@ def test_apimodels_prompt_over_272k_bills_the_whole_request_at_the_long_context_ + 100_000 * row["cache_read_input_token_cost_above_272k_tokens"] + 20 * row["output_cost_per_token_above_272k_tokens"] ) + + +@pytest.mark.parametrize("model", OFF_PEAK_MODELS) +@pytest.mark.parametrize("moment", (_WEEKDAY_OFF_PEAK, _WEEKEND), ids=("weekday-off-peak", "weekend")) +def test_apimodels_deepseek_rows_bill_half_rate_outside_weekday_peak_hours(model: str, moment: datetime): + from litellm.cost_calculator import cost_per_token + + entry: Final = litellm.model_cost[model] + with pinned_billing_time(moment): + prompt_cost, completion_cost = cost_per_token( + model=model, + prompt_tokens=1_000, + completion_tokens=1_000, + custom_llm_provider="apimodels", + ) + + assert prompt_cost == pytest.approx(entry["input_cost_per_token"] / 2 * 1_000) + assert completion_cost == pytest.approx(entry["output_cost_per_token"] / 2 * 1_000) + + +def test_apimodels_off_peak_rows_are_the_deepseek_flash_models(): + assert OFF_PEAK_MODELS == ("apimodels/deepseek-v4-flash", "apimodels/deepseek-v4.1-flash")