diff --git a/litellm/constants.py b/litellm/constants.py index ef9329b9dfce..a4276722265d 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -848,6 +848,7 @@ "https://serverless.tensormesh.ai/v1", "https://api.stima.tech/v1", "https://nano-gpt.com/api/v1", + "https://api.aitokenking.com.tw/api/v1", "https://api.poe.com/v1", "https://llm.chutes.ai/v1/", "https://api.v0.dev/v1", @@ -932,6 +933,7 @@ "docker_model_runner", "ragflow", "pinstripes", # Pinstripes - JSON-configured provider + "aitokenking", "darkbloom", "meta", # Meta Model API (Muse Spark) - JSON-configured provider "cognition", diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index a458a209ea91..b164a0711d2f 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -200,5 +200,16 @@ "temperature_max": 1.99 }, "supported_endpoints": ["/v1/chat/completions"] + }, + "aitokenking": { + "base_url": "https://api.aitokenking.com.tw/api/v1", + "api_key_env": "AITOKENKING_API_KEY", + "api_base_env": "AITOKENKING_API_BASE", + "param_mappings": { + "max_completion_tokens": "max_tokens" + }, + "supported_endpoints": [ + "/v1/chat/completions" + ] } } diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index d8a8f84b0323..8831451a58a2 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -58456,5 +58456,389 @@ "supported_endpoints": [ "/v1/audio/transcriptions" ] + }, + "aitokenking/claude-fable-5": { + "input_cost_per_token": 1e-05, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.6": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.7": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.8": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-5": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-sonnet-4.6": { + "input_cost_per_token": 3e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-sonnet-5": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v3.2": { + "input_cost_per_token": 5.699999999999999e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.71e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v4-flash": { + "input_cost_per_token": 1.4e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.8e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v4-pro": { + "input_cost_per_token": 1.74e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3.48e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-0-mini": { + "input_cost_per_token": 2.0000000000000002e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 8.000000000000001e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-0-mini-white": { + "input_cost_per_token": 2.0000000000000002e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 8.000000000000001e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-1-turbo": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-code": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-lite": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-pro": { + "input_cost_per_token": 1e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gemini-3-flash-preview": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gemini-3.1-pro-preview": { + "input_cost_per_token": 4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 1.8e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5": { + "input_cost_per_token": 1e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 3.2000000000000003e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5-turbo": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.1": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.2": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.3": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5v-turbo": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5-nano": { + "input_cost_per_token": 5.0000000000000004e-08, + "litellm_provider": "aitokenking", + "max_input_tokens": 400000, + "mode": "chat", + "output_cost_per_token": 4.0000000000000003e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.4": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 2.25e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.5": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 3e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-luna": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 9e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-sol": { + "input_cost_per_token": 1e-05, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 4.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-terra": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 2.25e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.5": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.6": { + "input_cost_per_token": 8.58e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 3.566e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.7-code": { + "input_cost_per_token": 9.499999999999999e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.7-code-highspeed": { + "input_cost_per_token": 1.8999999999999998e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 8e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k3": { + "input_cost_per_token": 3e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m2.5": { + "input_cost_per_token": 3e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m2.7": { + "input_cost_per_token": 3e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m3": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-max": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-max-white": { + "input_cost_per_token": 2.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 1.2e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-vl-flash": { + "input_cost_per_token": 7.5e-08, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 6e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-vl-plus": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 4.8e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.5-plus": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.5-plus-white": { + "input_cost_per_token": 4.0000000000000003e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.6-plus": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.7-max": { + "input_cost_per_token": 2.5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 7.5e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.7-plus": { + "input_cost_per_token": 4.0000000000000003e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.6000000000000001e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.8-max": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" } } diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 569fce4f7b8e..bf2566e9b4c5 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -3906,6 +3906,7 @@ class LlmProviders(str, Enum): TENSORMESH = "tensormesh" LIBERTAI = "libertai" PINSTRIPES = "pinstripes" + AITOKENKING = "aitokenking" COGNITION = "cognition" SCX_AI = "scx-ai" DARKBLOOM = "darkbloom" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index d8a8f84b0323..8831451a58a2 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -58456,5 +58456,389 @@ "supported_endpoints": [ "/v1/audio/transcriptions" ] + }, + "aitokenking/claude-fable-5": { + "input_cost_per_token": 1e-05, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.6": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.7": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-4.8": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-opus-5": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-sonnet-4.6": { + "input_cost_per_token": 3e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/claude-sonnet-5": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v3.2": { + "input_cost_per_token": 5.699999999999999e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 128000, + "mode": "chat", + "output_cost_per_token": 1.71e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v4-flash": { + "input_cost_per_token": 1.4e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.8e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/deepseek-v4-pro": { + "input_cost_per_token": 1.74e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3.48e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-0-mini": { + "input_cost_per_token": 2.0000000000000002e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 8.000000000000001e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-0-mini-white": { + "input_cost_per_token": 2.0000000000000002e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 8.000000000000001e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2-1-turbo": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 2.5e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-code": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-lite": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/dola-seed-2.0-pro": { + "input_cost_per_token": 1e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 262144, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gemini-3-flash-preview": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gemini-3.1-pro-preview": { + "input_cost_per_token": 4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 1.8e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5": { + "input_cost_per_token": 1e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 3.2000000000000003e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5-turbo": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.1": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.2": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5.3": { + "input_cost_per_token": 1.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 4.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/glm-5v-turbo": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5-nano": { + "input_cost_per_token": 5.0000000000000004e-08, + "litellm_provider": "aitokenking", + "max_input_tokens": 400000, + "mode": "chat", + "output_cost_per_token": 4.0000000000000003e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.4": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 2.25e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.5": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 3e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-luna": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 9e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-sol": { + "input_cost_per_token": 1e-05, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 4.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/gpt-5.6-terra": { + "input_cost_per_token": 5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1050000, + "mode": "chat", + "output_cost_per_token": 2.25e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.5": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.6": { + "input_cost_per_token": 8.58e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 3.566e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.7-code": { + "input_cost_per_token": 9.499999999999999e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k2.7-code-highspeed": { + "input_cost_per_token": 1.8999999999999998e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 8e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/kimi-k3": { + "input_cost_per_token": 3e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m2.5": { + "input_cost_per_token": 3e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m2.7": { + "input_cost_per_token": 3e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 200000, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/minimax-m3": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-max": { + "input_cost_per_token": 1.2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-max-white": { + "input_cost_per_token": 2.4e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 1.2e-05, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-vl-flash": { + "input_cost_per_token": 7.5e-08, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 6e-07, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3-vl-plus": { + "input_cost_per_token": 6e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 256000, + "mode": "chat", + "output_cost_per_token": 4.8e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.5-plus": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.5-plus-white": { + "input_cost_per_token": 4.0000000000000003e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.6-plus": { + "input_cost_per_token": 5e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 3e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.7-max": { + "input_cost_per_token": 2.5e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 7.5e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.7-plus": { + "input_cost_per_token": 4.0000000000000003e-07, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 1.6000000000000001e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" + }, + "aitokenking/qwen3.8-max": { + "input_cost_per_token": 2e-06, + "litellm_provider": "aitokenking", + "max_input_tokens": 1000000, + "mode": "chat", + "output_cost_per_token": 6e-06, + "source": "https://www.aitokenking.com.tw/assets/docs/zh/index.html" } } diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index ebc220b34965..eb8f02c79149 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -3026,6 +3026,23 @@ "rerank": false, "a2a": false } + }, + "aitokenking": { + "display_name": "AI Token King (`aitokenking`)", + "url": "https://docs.litellm.ai/docs/providers/aitokenking", + "endpoints": { + "chat_completions": true, + "messages": false, + "responses": false, + "embeddings": false, + "image_generations": false, + "audio_transcriptions": false, + "audio_speech": false, + "moderations": false, + "batches": false, + "rerank": false, + "a2a": false + } } }, "endpoints": { diff --git a/tests/test_litellm/llms/openai_like/test_aitokenking_provider.py b/tests/test_litellm/llms/openai_like/test_aitokenking_provider.py new file mode 100644 index 000000000000..69b6d8d868d0 --- /dev/null +++ b/tests/test_litellm/llms/openai_like/test_aitokenking_provider.py @@ -0,0 +1,205 @@ +""" +Tests for the AI Token King provider (JSON-configured, OpenAI-compatible gateway). +""" + +import json +from pathlib import Path + +import litellm +import pytest + +BASE_URL = "https://api.aitokenking.com.tw/api/v1" + + +class TestAITokenKingProviderConfig: + """AI Token King provider configuration and resolution.""" + + def test_aitokenking_in_provider_list(self): + from litellm import LlmProviders + + assert hasattr(LlmProviders, "AITOKENKING") + assert LlmProviders.AITOKENKING.value == "aitokenking" + assert "aitokenking" in litellm.provider_list + + def test_aitokenking_json_config_exists(self): + from litellm.llms.openai_like.json_loader import JSONProviderRegistry + + assert JSONProviderRegistry.exists("aitokenking") + + cfg = JSONProviderRegistry.get("aitokenking") + assert cfg is not None + assert cfg.base_url == BASE_URL + assert cfg.api_key_env == "AITOKENKING_API_KEY" + assert cfg.api_base_env == "AITOKENKING_API_BASE" + assert cfg.param_mappings.get("max_completion_tokens") == "max_tokens" + assert cfg.supported_endpoints == ["/v1/chat/completions"] + + def test_aitokenking_in_openai_compatible_providers(self): + from litellm.constants import openai_compatible_endpoints, openai_compatible_providers + + assert "aitokenking" in openai_compatible_providers + assert BASE_URL in openai_compatible_endpoints + + def test_aitokenking_provider_resolution(self): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + model, provider, api_key, api_base = get_llm_provider( + model="aitokenking/qwen3.7-max", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert model == "qwen3.7-max" + assert provider == "aitokenking" + assert api_base == BASE_URL + + def test_aitokenking_api_base_override(self): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + model, provider, api_key, api_base = get_llm_provider( + model="aitokenking/qwen3.7-max", + custom_llm_provider=None, + api_base="https://custom.example.com/v1", + api_key="sk-test", + ) + + assert provider == "aitokenking" + assert api_base == "https://custom.example.com/v1" + assert api_key == "sk-test" + + def test_aitokenking_url_autodetection(self): + """Passing the gateway's api_base without a prefix resolves the provider.""" + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + model, provider, api_key, api_base = get_llm_provider( + model="qwen3.7-max", + custom_llm_provider=None, + api_base=BASE_URL, + api_key=None, + ) + assert provider == "aitokenking" + assert api_base == BASE_URL + + +class TestAITokenKingPricing: + """Cost tracking is the point of shipping the price map with the provider.""" + + @staticmethod + def _load_price_map() -> dict: + json_path = Path(__file__).parents[4] / "model_prices_and_context_window.json" + with open(json_path) as f: + return json.load(f) + + def test_price_map_entries_use_provider_prefix(self): + model_cost = self._load_price_map() + keys = [k for k in model_cost if k.startswith("aitokenking/")] + assert len(keys) == 48 + for k in keys: + entry = model_cost[k] + assert entry["litellm_provider"] == "aitokenking" + assert entry["mode"] == "chat" + # A zero price would read as "free" rather than "unknown"; never ship one. + assert entry["input_cost_per_token"] > 0 + assert entry["output_cost_per_token"] > 0 + + def test_prefixed_keys_do_not_shadow_upstream_vendor_entries(self): + """Some gateway model ids match vendor ids already in the map (e.g. gpt-5.5). + + The gateway resells at its own price, so the entry must live under the + provider prefix only — a bare-id entry would overwrite the vendor's price + for everyone. + """ + model_cost = self._load_price_map() + for bare in ("gpt-5.5", "claude-sonnet-5", "gemini-3.1-pro-preview"): + assert f"aitokenking/{bare}" in model_cost + assert model_cost[bare]["litellm_provider"] != "aitokenking" + + def test_completion_cost_resolves_for_prefixed_model(self, monkeypatch): + from litellm.types.utils import ModelResponse + + model = "aitokenking/qwen3.7-max" + entry = self._load_price_map()[model] + monkeypatch.setitem(litellm.model_cost, model, entry) + + prompt_tokens, completion_tokens = 100_000, 100_000 + expected = entry["input_cost_per_token"] * prompt_tokens + entry["output_cost_per_token"] * completion_tokens + + response = ModelResponse( + **{ + "id": "chatcmpl-test", + "object": "chat.completion", + "created": 0, + "model": model, + "choices": [ + { + "index": 0, + "finish_reason": "stop", + "message": {"role": "assistant", "content": "ok"}, + } + ], + "usage": { + "prompt_tokens": prompt_tokens, + "completion_tokens": completion_tokens, + "total_tokens": prompt_tokens + completion_tokens, + }, + } + ) + + cost = litellm.completion_cost(completion_response=response, model=model) + assert abs(cost - expected) < 1e-9 + assert cost > 0 + +class TestAITokenKingRouting: + """Exercises the dispatch path, not just the stored configuration.""" + + @staticmethod + def _router(): + from litellm import Router + + return Router( + model_list=[ + { + "model_name": "atk-chat", + "litellm_params": { + "model": "aitokenking/qwen3.7-max", + "api_key": "sk-test", + }, + } + ] + ) + + @pytest.mark.asyncio + async def test_routed_request_targets_the_gateway_with_the_prefix_stripped(self): + """The prefix selects the provider; it must not reach the wire.""" + response = await self._router().acompletion( + model="atk-chat", + messages=[{"role": "user", "content": "hi"}], + mock_response="ok", + ) + + assert response._hidden_params["api_base"] == BASE_URL + assert response.model == "qwen3.7-max" + + @pytest.mark.asyncio + async def test_routed_spend_is_costed_off_the_aitokenking_entry(self): + """Router registers every deployment, so an unmapped model silently costs 0.0. + + This is the regression the price map exists to prevent: assert the routed + response is costed from the aitokenking entry rather than defaulting to zero. + """ + entry = TestAITokenKingPricing._load_price_map()["aitokenking/qwen3.7-max"] + + response = await self._router().acompletion( + model="atk-chat", + messages=[{"role": "user", "content": "hi"}], + mock_response="ok", + ) + + usage = response.usage + expected = ( + usage.prompt_tokens * entry["input_cost_per_token"] + + usage.completion_tokens * entry["output_cost_per_token"] + ) + assert response._hidden_params["response_cost"] == pytest.approx(expected) + assert response._hidden_params["response_cost"] > 0