diff --git a/README.md b/README.md index 1624d408419..38191eea891 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ For MCP OAuth, an upstream may advertise dynamic client registration but refuse | [AI/ML API (`aiml`)](https://docs.litellm.ai/docs/providers/aiml) | ✅ | ✅ | ✅ | ✅ | ✅ | | | | | | | [AI21 (`ai21`)](https://docs.litellm.ai/docs/providers/ai21) | ✅ | ✅ | ✅ | | | | | | | | | [AI21 Chat (`ai21_chat`)](https://docs.litellm.ai/docs/providers/ai21) | ✅ | ✅ | ✅ | | | | | | | | +| [ainetcafe (`ainetcafe`)](https://docs.litellm.ai/docs/providers/ainetcafe) | ✅ | | | | | | | | | | | [Aleph Alpha](https://docs.litellm.ai/docs/providers/aleph_alpha) | ✅ | ✅ | ✅ | | | | | | | | | [Amazon Nova](https://docs.litellm.ai/docs/providers/amazon_nova) | ✅ | ✅ | ✅ | | | | | | | | | [Anthropic (`anthropic`)](https://docs.litellm.ai/docs/providers/anthropic) | ✅ | ✅ | ✅ | | | | | | ✅ | | diff --git a/litellm/constants.py b/litellm/constants.py index bbeb4846e27..e78cf4a1151 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -928,6 +928,7 @@ openai_compatible_endpoints: Final[list] = [ "https://api.meta.ai/v1", "https://api.cognition.ai/v1", "https://api.scx.ai/v1", + "https://microquickjs.com/v1", "https://gigachat.devices.sberbank.ru/api/v1", ] @@ -1000,6 +1001,7 @@ openai_compatible_providers: Final[list] = [ "meta", # Meta Model API (Muse Spark) - JSON-configured provider "cognition", "scx-ai", + "ainetcafe", # ainetcafe (Kimi K3) - JSON-configured provider ] 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 fe10293c420..4826efbe1dd 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -200,5 +200,11 @@ "temperature_max": 1.99 }, "supported_endpoints": ["/v1/chat/completions"] + }, + "ainetcafe": { + "base_url": "https://microquickjs.com/v1", + "api_key_env": "AINETCAFE_API_KEY", + "api_base_env": "AINETCAFE_API_BASE", + "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 3bc8b3c176c..a3b14bfe743 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -45299,6 +45299,23 @@ "supports_tool_choice": true, "supports_vision": true }, + "ainetcafe/Kimi-K3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 2.1e-06, + "litellm_provider": "ainetcafe", + "max_input_tokens": 262144, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 1.05e-05, + "source": "https://ainetcafe.com/k3/#pricing", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, "snowflake/claude-3-5-sonnet": { "litellm_provider": "snowflake", "max_input_tokens": 200000, diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index 30c1e0b894e..275faee309e 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -2082,6 +2082,23 @@ "a2a": false } }, + "ainetcafe": { + "display_name": "ainetcafe (`ainetcafe`)", + "url": "https://docs.litellm.ai/docs/providers/ainetcafe", + "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 + } + }, "snowflake": { "display_name": "Snowflake (`snowflake`)", "url": "https://docs.litellm.ai/docs/providers/snowflake", diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index d7e100dd630..a14ef267c8e 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -2985,6 +2985,34 @@ ], "default_model_placeholder": "scx-ai/GLM-5.2" }, + { + "provider": "AINETCAFE", + "provider_display_name": "ainetcafe", + "litellm_provider": "ainetcafe", + "credential_fields": [ + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://microquickjs.com/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": "ainetcafe/Kimi-K3" + }, { "provider": "Snowflake", "provider_display_name": "Snowflake", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5a80644347e..81e84d32f17 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4175,6 +4175,7 @@ class LlmProviders(str, Enum): PINSTRIPES = "pinstripes" COGNITION = "cognition" SCX_AI = "scx-ai" + AINETCAFE = "ainetcafe" DARKBLOOM = "darkbloom" META = "meta" LITELLM_AGENT = "litellm_agent" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 3bc8b3c176c..a3b14bfe743 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -45299,6 +45299,23 @@ "supports_tool_choice": true, "supports_vision": true }, + "ainetcafe/Kimi-K3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 2.1e-06, + "litellm_provider": "ainetcafe", + "max_input_tokens": 262144, + "max_output_tokens": 131072, + "max_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 1.05e-05, + "source": "https://ainetcafe.com/k3/#pricing", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_vision": true + }, "snowflake/claude-3-5-sonnet": { "litellm_provider": "snowflake", "max_input_tokens": 200000, diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index af9b194bbee..614116e03e8 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -2316,6 +2316,23 @@ "a2a": false } }, + "ainetcafe": { + "display_name": "ainetcafe (`ainetcafe`)", + "url": "https://docs.litellm.ai/docs/providers/ainetcafe", + "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 + } + }, "snowflake": { "display_name": "Snowflake (`snowflake`)", "url": "https://docs.litellm.ai/docs/providers/snowflake", diff --git a/tests/test_litellm/llms/openai_like/test_ainetcafe_provider.py b/tests/test_litellm/llms/openai_like/test_ainetcafe_provider.py new file mode 100644 index 00000000000..fd4874efaa6 --- /dev/null +++ b/tests/test_litellm/llms/openai_like/test_ainetcafe_provider.py @@ -0,0 +1,166 @@ +""" +Tests for the ainetcafe (Kimi K3) provider: request routing, parameter passthrough, +cost tracking and the consistency of its metadata across the config surfaces. +""" + +import json +from pathlib import Path + +import pytest +import respx +from httpx import Response + +import litellm + +BASE_URL = "https://microquickjs.com/v1" +MODEL = "ainetcafe/Kimi-K3" + + +def _chat_response(prompt_tokens=100, cached_tokens=60, completion_tokens=20): + return { + "id": "chatcmpl-ainetcafe-test", + "object": "chat.completion", + "created": 1758000000, + "model": "Kimi-K3", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "LiteLLM OK", + "reasoning_content": "The user wants an exact reply.", + }, + "finish_reason": "stop", + } + ], + "usage": { + "prompt_tokens": prompt_tokens, + "completion_tokens": completion_tokens, + "total_tokens": prompt_tokens + completion_tokens, + "prompt_tokens_details": {"cached_tokens": cached_tokens}, + }, + } + + +@pytest.fixture(autouse=True) +def _local_cost_map(monkeypatch): + monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True") + litellm.model_cost = litellm.get_model_cost_map(url="") + + +class TestAinetcafeRequests: + @respx.mock + def test_completion_hits_default_base_with_bearer_key_and_passes_reasoning_params(self): + route = respx.post(f"{BASE_URL}/chat/completions").mock(return_value=Response(200, json=_chat_response())) + + response = litellm.completion( + model=MODEL, + messages=[{"role": "user", "content": "Reply with exactly: LiteLLM OK"}], + api_key="sk-test-ainetcafe", + reasoning_effort="high", + max_completion_tokens=256, + ) + + assert route.called + request = route.calls.last.request + assert request.headers["authorization"] == "Bearer sk-test-ainetcafe" + body = json.loads(request.content) + assert body["model"] == "Kimi-K3" + assert body["reasoning_effort"] == "high" + assert body["max_completion_tokens"] == 256 + assert response.choices[0].message.content == "LiteLLM OK" + assert response.choices[0].message.reasoning_content == "The user wants an exact reply." + + @respx.mock + def test_api_key_env_and_api_base_env_are_honoured(self, monkeypatch): + monkeypatch.setenv("AINETCAFE_API_KEY", "sk-from-env") + monkeypatch.setenv("AINETCAFE_API_BASE", "https://dedicated.example.com/v1") + route = respx.post("https://dedicated.example.com/v1/chat/completions").mock( + return_value=Response(200, json=_chat_response()) + ) + + litellm.completion(model=MODEL, messages=[{"role": "user", "content": "hi"}]) + + assert route.called + assert route.calls.last.request.headers["authorization"] == "Bearer sk-from-env" + + def test_base_url_autodetects_provider(self): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + model, provider, _, api_base = get_llm_provider( + model="Kimi-K3", custom_llm_provider=None, api_base=BASE_URL, api_key=None + ) + + assert (model, provider, api_base) == ("Kimi-K3", "ainetcafe", BASE_URL) + + @respx.mock + def test_completion_cost_uses_cost_map_and_cached_input_rate(self): + respx.post(f"{BASE_URL}/chat/completions").mock( + return_value=Response(200, json=_chat_response(prompt_tokens=100, cached_tokens=60, completion_tokens=20)) + ) + info = litellm.get_model_info(MODEL) + + response = litellm.completion(model=MODEL, messages=[{"role": "user", "content": "hi"}], api_key="sk-test") + cost = litellm.completion_cost(completion_response=response) + + expected = ( + 40 * info["input_cost_per_token"] + + 60 * info["cache_read_input_token_cost"] + + 20 * info["output_cost_per_token"] + ) + assert cost == pytest.approx(expected) + assert 0 < info["cache_read_input_token_cost"] < info["input_cost_per_token"] < info["output_cost_per_token"] + + +class TestAinetcafeMetadataConsistency: + @staticmethod + def _load(*parts): + with open(Path(__file__).parents[4].joinpath(*parts)) as f: + return json.load(f) + + def test_model_entry_matches_backup_and_declares_capabilities_the_provider_serves(self): + root = self._load("model_prices_and_context_window.json")[MODEL] + backup = self._load("litellm", "model_prices_and_context_window_backup.json")[MODEL] + + assert root == backup + assert root["litellm_provider"] == "ainetcafe" + assert root["max_tokens"] == root["max_output_tokens"] <= root["max_input_tokens"] + # Source: https://ainetcafe.com/k3/#pricing and https://ainetcafe.com/k3/verifier.html, read 2026-09-17. + # Kimi K3 on ainetcafe reasons, calls tools, returns JSON schema output and takes image input. + assert all( + root[flag] + for flag in ( + "supports_reasoning", + "supports_function_calling", + "supports_tool_choice", + "supports_response_schema", + "supports_vision", + "supports_prompt_caching", + ) + ) + + def test_provider_surfaces_agree_on_slug_base_url_and_env_keys(self): + from litellm.llms.openai_like.json_loader import JSONProviderRegistry + + provider = JSONProviderRegistry.get("ainetcafe") + assert provider is not None + + create_fields = [ + e + for e in self._load("litellm", "proxy", "public_endpoints", "provider_create_fields.json") + if e["litellm_provider"] == "ainetcafe" + ] + assert len(create_fields) == 1 + api_base_field = next(f for f in create_fields[0]["credential_fields"] if f["key"] == "api_base") + assert api_base_field["placeholder"] == provider.base_url + assert create_fields[0]["default_model_placeholder"] == MODEL + + support = self._load("provider_endpoints_support.json")["providers"]["ainetcafe"] + support_backup = self._load("litellm", "provider_endpoints_support_backup.json")["providers"]["ainetcafe"] + assert support == support_backup + assert support["endpoints"]["chat_completions"] is ("/v1/chat/completions" in provider.supported_endpoints) + + from litellm.constants import openai_compatible_endpoints, openai_compatible_providers + + assert "ainetcafe" in openai_compatible_providers + assert provider.base_url in openai_compatible_endpoints diff --git a/ui/litellm-dashboard/public/assets/logos/ainetcafe.svg b/ui/litellm-dashboard/public/assets/logos/ainetcafe.svg new file mode 100644 index 00000000000..497be12efaa --- /dev/null +++ b/ui/litellm-dashboard/public/assets/logos/ainetcafe.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx b/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx index 4c68e302267..7ccf7deaa3e 100644 --- a/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx +++ b/ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx @@ -73,6 +73,17 @@ describe("provider_info_helpers", () => { expect(fromEnumKey.logo).toBe(providerLogoMap[Providers.SCX_AI]); }); + it("should map ainetcafe slug and AINETCAFE enum key to the ainetcafe display name and logo", () => { + const fromSlug = getProviderLogoAndName("ainetcafe"); + expect(fromSlug.displayName).toBe(Providers.AINETCAFE); + expect(fromSlug.logo).toBe(providerLogoMap[Providers.AINETCAFE]); + expect(fromSlug.logo).toBeTruthy(); + + const fromEnumKey = getProviderLogoAndName("AINETCAFE"); + expect(fromEnumKey.displayName).toBe(Providers.AINETCAFE); + expect(fromEnumKey.logo).toBe(providerLogoMap[Providers.AINETCAFE]); + }); + it("should map bedrock_mantle slug to Bedrock Mantle display name and logo", () => { const result = getProviderLogoAndName("bedrock_mantle"); expect(result.displayName).toBe(Providers.BedrockMantle); @@ -205,6 +216,10 @@ describe("provider_info_helpers", () => { expect(getPlaceholder(Providers.SCX_AI)).toBe("scx-ai/GLM-5.2"); }); + it("should return an ainetcafe model placeholder for AINETCAFE provider", () => { + expect(getPlaceholder(Providers.AINETCAFE)).toBe("ainetcafe/Kimi-K3"); + }); + it("should return claude-3-opus placeholder for Anthropic provider", () => { expect(getPlaceholder(Providers.Anthropic)).toBe("claude-3-opus"); }); diff --git a/ui/litellm-dashboard/src/components/provider_info_helpers.tsx b/ui/litellm-dashboard/src/components/provider_info_helpers.tsx index 1a1a2fd73aa..fc0d5e4cc61 100644 --- a/ui/litellm-dashboard/src/components/provider_info_helpers.tsx +++ b/ui/litellm-dashboard/src/components/provider_info_helpers.tsx @@ -52,6 +52,7 @@ import runwayLogo from "../../public/assets/logos/runway.png"; import sambanovaLogo from "../../public/assets/logos/sambanova.svg"; import sapLogo from "../../public/assets/logos/sap.png"; import scxAiLogo from "../../public/assets/logos/scx_ai.svg"; +import ainetcafeLogo from "../../public/assets/logos/ainetcafe.svg"; import snowflakeLogo from "../../public/assets/logos/snowflake.svg"; import sonioxLogo from "../../public/assets/logos/soniox.svg"; import togetheraiLogo from "../../public/assets/logos/togetherai.svg"; @@ -161,6 +162,7 @@ export enum Providers { Sambanova = "Sambanova", SAP = "SAP Generative AI Hub", SCX_AI = "SCX.ai", + AINETCAFE = "ainetcafe", Snowflake = "Snowflake", Soniox = "Soniox", TEXT_COMPLETION_CODESTRAL = "Text-Completion-Codestral", @@ -278,6 +280,7 @@ export const provider_map: Record = { Sambanova: "sambanova", SAP: "sap", SCX_AI: "scx-ai", + AINETCAFE: "ainetcafe", Snowflake: "snowflake", Soniox: "soniox", TEXT_COMPLETION_CODESTRAL: "text-completion-codestral", @@ -376,6 +379,7 @@ export const providerLogoMap: Partial> = { [Providers.Sambanova]: sambanovaLogo.src, [Providers.SAP]: sapLogo.src, [Providers.SCX_AI]: scxAiLogo.src, + [Providers.AINETCAFE]: ainetcafeLogo.src, [Providers.Snowflake]: snowflakeLogo.src, [Providers.Soniox]: sonioxLogo.src, [Providers.TEXT_COMPLETION_CODESTRAL]: mistralLogo.src, @@ -444,6 +448,7 @@ const providerPlaceholderMap: Partial> = { [Providers.RunwayML]: "runwayml/gen4_turbo", [Providers.SageMaker]: "sagemaker/jumpstart-dft-meta-textgeneration-llama-2-7b", [Providers.SCX_AI]: "scx-ai/GLM-5.2", + [Providers.AINETCAFE]: "ainetcafe/Kimi-K3", [Providers.Snowflake]: "snowflake/mistral-7b", [Providers.Vertex_AI]: "gemini-pro", [Providers.VolcEngine]: "volcengine/",