This commit is contained in:
Mallard AI 2026-11-03 08:13:38 +00:00 • committed by GitHub
commit af49951c76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 317 additions and 0 deletions

View file

@ -1095,6 +1095,7 @@ openai_compatible_endpoints: Final[list[str]] = [
"https://gigachat.devices.sberbank.ru/api/v1",
"https://api.openinfer.ai/v1",
"https://vanchin.streamlake.ai/api/gateway/v1/endpoints",
"https://api.mallardai.co.uk/v1",
]
@ -1179,6 +1180,7 @@ openai_compatible_providers: Final[list[str]] = [
"sail",
"reka",
"streamlake",
"mallard",
]
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))

View file

@ -302,5 +302,10 @@
"preserve_cache_control": true
},
"supported_endpoints": ["/v1/chat/completions"]
},
"mallard": {
"base_url": "https://api.mallardai.co.uk/v1",
"api_key_env": "MALLARD_API_KEY",
"api_base_env": "MALLARD_API_BASE"
}
}

View file

@ -77245,6 +77245,23 @@
"supports_reasoning": true,
"source": "https://api.openinfer.ai/v1/models"
},
"mallard/qwen/qwen3.6-35b-a3b": {
"max_tokens": 235929,
"max_input_tokens": 262144,
"max_output_tokens": 235929,
"input_cost_per_token": 1.06944e-07,
"cache_read_input_token_cost": 8.0208e-08,
"output_cost_per_token": 1.0026e-06,
"litellm_provider": "mallard",
"mode": "chat",
"supports_function_calling": true,
"supports_tool_choice": true,
"supports_vision": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_prompt_caching": true,
"source": "https://mallardai.co.uk/pricing/"
},
"openinfer/@oi/Qwen3.5-27B": {
"max_input_tokens": 32768,
"max_output_tokens": 32768,

View file

@ -5276,6 +5276,24 @@
"generateContent": false
}
},
"mallard": {
"display_name": "Mallard AI (`mallard`)",
"url": "https://docs.litellm.ai/docs/providers/mallard",
"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
}
},
"openinfer": {
"display_name": "OpenInfer (`openinfer`)",
"url": "https://docs.litellm.ai/docs/providers/openinfer",

View file

@ -3539,6 +3539,34 @@
],
"default_model_placeholder": "gpt-3.5-turbo"
},
{
"provider": "MALLARD",
"provider_display_name": "Mallard AI",
"litellm_provider": "mallard",
"credential_fields": [
{
"key": "api_base",
"label": "API Base",
"placeholder": "https://api.mallardai.co.uk/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": "mallard/qwen/qwen3.6-35b-a3b"
},
{
"provider": "REKA",
"provider_display_name": "Reka",

View file

@ -4756,6 +4756,7 @@ class LlmProviders(str, Enum):
SAIL = "sail"
REKA = "reka"
STREAMLAKE = "streamlake"
MALLARD = "mallard"
LITELLM_AGENT = "litellm_agent"
CURSOR = "cursor"
BEDROCK_MANTLE = "bedrock_mantle"

View file

@ -77245,6 +77245,23 @@
"supports_reasoning": true,
"source": "https://api.openinfer.ai/v1/models"
},
"mallard/qwen/qwen3.6-35b-a3b": {
"max_tokens": 235929,
"max_input_tokens": 262144,
"max_output_tokens": 235929,
"input_cost_per_token": 1.06944e-07,
"cache_read_input_token_cost": 8.0208e-08,
"output_cost_per_token": 1.0026e-06,
"litellm_provider": "mallard",
"mode": "chat",
"supports_function_calling": true,
"supports_tool_choice": true,
"supports_vision": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_prompt_caching": true,
"source": "https://mallardai.co.uk/pricing/"
},
"openinfer/@oi/Qwen3.5-27B": {
"max_input_tokens": 32768,
"max_output_tokens": 32768,

View file

@ -5276,6 +5276,24 @@
"generateContent": false
}
},
"mallard": {
"display_name": "Mallard AI (`mallard`)",
"url": "https://docs.litellm.ai/docs/providers/mallard",
"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
}
},
"openinfer": {
"display_name": "OpenInfer (`openinfer`)",
"url": "https://docs.litellm.ai/docs/providers/openinfer",

View file

@ -0,0 +1,211 @@
import json
from pathlib import Path
from typing import Final
import pytest
import respx
import litellm
from litellm.caching.llm_caching_handler import LLMClientCache
_CHAT_COMPLETION: Final = {
"id": "chatcmpl_mallard",
"object": "chat.completion",
"created": 1_790_000_000,
"model": "qwen/qwen3.6-35b-a3b",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello from Mallard AI"},
"finish_reason": "stop",
}
],
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
}
def test_mallard_is_a_registered_provider():
assert litellm.LlmProviders.MALLARD.value == "mallard"
assert "mallard" in litellm.provider_list
assert "mallard" in litellm.constants.openai_compatible_providers
def test_mallard_provider_resolution(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("MALLARD_API_KEY", "mallard-test-key")
model, provider, api_key, api_base = get_llm_provider(
model="mallard/qwen/qwen3.6-35b-a3b",
custom_llm_provider=None,
api_base=None,
api_key=None,
)
assert model == "qwen/qwen3.6-35b-a3b"
assert provider == "mallard"
assert api_key == "mallard-test-key"
assert api_base == "https://api.mallardai.co.uk/v1"
def test_mallard_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("MALLARD_API_KEY", "mallard-env-key")
monkeypatch.setenv("MALLARD_API_BASE", "https://mallard.env.example/v1")
_, provider, api_key, api_base = get_llm_provider(
model="mallard/qwen/qwen3.6-35b-a3b",
custom_llm_provider=None,
api_base="https://mallard.internal.example/v1",
api_key="mallard-explicit-key",
)
assert provider == "mallard"
assert api_key == "mallard-explicit-key"
assert api_base == "https://mallard.internal.example/v1"
def test_mallard_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("MALLARD_API_KEY", "mallard-env-key")
monkeypatch.setenv("MALLARD_API_BASE", "https://mallard.env.example/v1")
_, provider, _, api_base = get_llm_provider(
model="mallard/qwen/qwen3.6-35b-a3b",
custom_llm_provider=None,
api_base=None,
api_key=None,
)
assert provider == "mallard"
assert api_base == "https://mallard.env.example/v1"
def test_mallard_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("MALLARD_API_KEY", "mallard-env-key")
model, provider, api_key, api_base = get_llm_provider(
model="qwen/qwen3.6-35b-a3b",
custom_llm_provider=None,
api_base="https://api.mallardai.co.uk/v1",
api_key=None,
)
assert model == "qwen/qwen3.6-35b-a3b"
assert provider == "mallard"
assert api_key == "mallard-env-key"
assert api_base == "https://api.mallardai.co.uk/v1"
def test_mallard_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())
mallard = next(provider for provider in providers if provider["litellm_provider"] == "mallard")
assert mallard["provider"] == "MALLARD"
assert mallard["provider_display_name"] == "Mallard AI"
assert mallard["default_model_placeholder"] == "mallard/qwen/qwen3.6-35b-a3b"
assert {field["key"]: field["required"] for field in mallard["credential_fields"]} == {
"api_base": False,
"api_key": True,
}
def test_mallard_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"]["mallard"]["endpoints"] == expected
assert json.loads(root_path.read_text())["providers"]["mallard"]["endpoints"] == expected
def test_mallard_chat_completion_request():
with respx.mock() as upstream:
route: Final = upstream.post("https://api.mallardai.co.uk/v1/chat/completions").respond(200, json=_CHAT_COMPLETION)
response: Final = litellm.completion(
model="mallard/qwen/qwen3.6-35b-a3b",
messages=[{"role": "user", "content": "Say hello"}],
api_key="mallard-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == "https://api.mallardai.co.uk/v1/chat/completions"
assert request.headers["authorization"] == "Bearer mallard-test-key"
assert body["model"] == "qwen/qwen3.6-35b-a3b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response.choices[0].message.content == "Hello from Mallard AI"
def test_mallard_responses_request_is_bridged_to_chat_completions():
with respx.mock() as upstream:
route: Final = upstream.post("https://api.mallardai.co.uk/v1/chat/completions").respond(200, json=_CHAT_COMPLETION)
response: Final = litellm.responses(
model="mallard/qwen/qwen3.6-35b-a3b",
input="Say hello",
api_key="mallard-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert request.headers["authorization"] == "Bearer mallard-test-key"
assert body["model"] == "qwen/qwen3.6-35b-a3b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response.output[0].content[0].text == "Hello from Mallard AI"
@pytest.mark.asyncio
async def test_mallard_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.mallardai.co.uk/v1/chat/completions").respond(200, json=_CHAT_COMPLETION)
response: Final = await litellm.anthropic.messages.acreate(
model="mallard/qwen/qwen3.6-35b-a3b",
messages=[{"role": "user", "content": "Say hello"}],
max_tokens=32,
api_key="mallard-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert request.headers["authorization"] == "Bearer mallard-test-key"
assert body["model"] == "qwen/qwen3.6-35b-a3b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert body["max_tokens"] == 32
assert response["content"][0]["text"] == "Hello from Mallard AI"
def test_mallard_model_prices_and_limits():
info: Final = litellm.get_model_info("mallard/qwen/qwen3.6-35b-a3b")
assert info["litellm_provider"] == "mallard"
assert info["max_input_tokens"] == 262_144
assert info["max_output_tokens"] == 235_929
assert info["input_cost_per_token"] == pytest.approx(1.06944e-07)
assert info["cache_read_input_token_cost"] == pytest.approx(8.0208e-08)
assert info["output_cost_per_token"] == pytest.approx(1.0026e-06)
assert info["supports_function_calling"] is True
assert info["supports_vision"] is True
assert info["supports_reasoning"] is True