This commit is contained in:
MarioF 2026-09-21 23:26:55 +08:00 • committed by GitHub
commit ad25fc9644
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 302 additions and 0 deletions

View file

@ -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) | ✅ | ✅ | ✅ | | | | | | ✅ | |

View file

@ -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))

View file

@ -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"]
}
}

View file

@ -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,

View file

@ -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",

View file

@ -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",

View file

@ -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"

View file

@ -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,

View file

@ -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",

View file

@ -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

View file

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#C9FF3A"/>
<stop offset="1" stop-color="#32FEA5"/>
</linearGradient>
</defs>
<rect width="256" height="256" rx="48" fill="#0B0F0E"/>
<path d="M152 14 L44 150 H118 L104 242 L212 106 H138 Z" fill="url(#g)"/>
</svg>

After

Width:  |  Height:  |  Size: 417 B

View file

@ -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");
});

View file

@ -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<string, string> = {
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<Record<Providers, string>> = {
[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<Record<Providers, string>> = {
[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/<any-model-on-volcengine>",