This commit is contained in:
jimmyplup 2026-10-20 04:45:08 +00:00 • committed by GitHub
commit 02d92bd416
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 278 additions and 0 deletions

View file

@ -1044,6 +1044,7 @@ openai_compatible_endpoints: Final[list[str]] = [
"https://api.scx.ai/v1",
"https://api.prisminference.com/v1",
"https://api.reka.ai/v1",
"https://pool.linkrra.com/v1",
"https://gigachat.devices.sberbank.ru/api/v1",
"https://api.openinfer.ai/v1",
]
@ -1124,6 +1125,7 @@ openai_compatible_providers: Final[list[str]] = [
"prism",
"sail",
"reka",
"linkrra",
]
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))

View file

@ -249,5 +249,11 @@
"/v1/responses",
"/v1/messages"
]
},
"linkrra": {
"base_url": "https://pool.linkrra.com/v1",
"api_key_env": "LINKRRA_API_KEY",
"api_base_env": "LINKRRA_API_BASE",
"supported_endpoints": ["/v1/chat/completions", "/v1/messages"]
}
}

View file

@ -2154,6 +2154,24 @@
"interactions": false
}
},
"linkrra": {
"display_name": "Linkrra (`linkrra`)",
"url": "https://docs.litellm.ai/docs/providers/linkrra",
"endpoints": {
"chat_completions": true,
"messages": true,
"responses": false,
"embeddings": false,
"image_generations": false,
"audio_transcriptions": false,
"audio_speech": false,
"moderations": false,
"batches": false,
"rerank": false,
"a2a": false,
"interactions": false
}
},
"scaleway": {
"display_name": "Scaleway (`scaleway`)",
"url": "https://docs.litellm.ai/docs/providers/scaleway",

View file

@ -3287,6 +3287,34 @@
],
"default_model_placeholder": "reka/reka-flash"
},
{
"provider": "LINKRRA",
"provider_display_name": "Linkrra",
"litellm_provider": "linkrra",
"credential_fields": [
{
"key": "api_base",
"label": "API Base",
"placeholder": "https://pool.linkrra.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": "linkrra/qwen3-coder-30b"
},
{
"provider": "Sail",
"provider_display_name": "Sail",

View file

@ -4522,6 +4522,7 @@ class LlmProviders(str, Enum):
META = "meta"
SAIL = "sail"
REKA = "reka"
LINKRRA = "linkrra"
LITELLM_AGENT = "litellm_agent"
CURSOR = "cursor"
BEDROCK_MANTLE = "bedrock_mantle"

View file

@ -3223,6 +3223,24 @@
"interactions": false
}
},
"linkrra": {
"display_name": "Linkrra (`linkrra`)",
"url": "https://docs.litellm.ai/docs/providers/linkrra",
"endpoints": {
"chat_completions": true,
"messages": true,
"responses": false,
"embeddings": false,
"image_generations": false,
"audio_transcriptions": false,
"audio_speech": false,
"moderations": false,
"batches": false,
"rerank": false,
"a2a": false,
"interactions": false
}
},
"charity_engine": {
"display_name": "Charity Engine (`charity_engine`)",
"url": "https://docs.litellm.ai/docs/providers/charity_engine",

View file

@ -0,0 +1,205 @@
import json
from typing import Final
import pytest
import respx
import litellm
from litellm.caching.llm_caching_handler import LLMClientCache
_API_BASE: Final = "https://pool.linkrra.com/v1"
_CHAT_COMPLETION: Final = {
"id": "chatcmpl_linkrra",
"object": "chat.completion",
"created": 1_790_000_000,
"model": "qwen3-coder-30b",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello from Linkrra"},
"finish_reason": "stop",
}
],
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
}
def test_linkrra_is_a_registered_provider():
assert litellm.LlmProviders.LINKRRA.value == "linkrra"
assert "linkrra" in litellm.provider_list
assert "linkrra" in litellm.constants.openai_compatible_providers
def test_linkrra_provider_resolution(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.delenv("LINKRRA_API_BASE", raising=False)
monkeypatch.setenv("LINKRRA_API_KEY", "linkrra-test-key")
model, provider, api_key, api_base = get_llm_provider(
model="linkrra/qwen3-coder-30b",
custom_llm_provider=None,
api_base=None,
api_key=None,
)
assert model == "qwen3-coder-30b"
assert provider == "linkrra"
assert api_key == "linkrra-test-key"
assert api_base == _API_BASE
def test_linkrra_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("LINKRRA_API_KEY", "linkrra-env-key")
monkeypatch.setenv("LINKRRA_API_BASE", "https://linkrra.env.example/v1")
_, provider, api_key, api_base = get_llm_provider(
model="linkrra/qwen3-coder-30b",
custom_llm_provider=None,
api_base="https://linkrra.internal.example/v1",
api_key="linkrra-explicit-key",
)
assert provider == "linkrra"
assert api_key == "linkrra-explicit-key"
assert api_base == "https://linkrra.internal.example/v1"
def test_linkrra_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("LINKRRA_API_KEY", "linkrra-env-key")
monkeypatch.setenv("LINKRRA_API_BASE", "https://linkrra.env.example/v1")
_, provider, _, api_base = get_llm_provider(
model="linkrra/qwen3-coder-30b",
custom_llm_provider=None,
api_base=None,
api_key=None,
)
assert provider == "linkrra"
assert api_base == "https://linkrra.env.example/v1"
def test_linkrra_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("LINKRRA_API_KEY", "linkrra-env-key")
model, provider, api_key, api_base = get_llm_provider(
model="qwen3-coder-30b",
custom_llm_provider=None,
api_base=_API_BASE,
api_key=None,
)
assert model == "qwen3-coder-30b"
assert provider == "linkrra"
assert api_key == "linkrra-env-key"
assert api_base == _API_BASE
@pytest.mark.asyncio
async def test_linkrra_is_served_by_the_add_model_form_endpoint():
from litellm.proxy.public_endpoints.public_endpoints import get_provider_fields
fields: Final = await get_provider_fields()
linkrra: Final = next(provider for provider in fields if provider.litellm_provider == "linkrra")
assert linkrra.provider_display_name == "Linkrra"
assert linkrra.default_model_placeholder == "linkrra/qwen3-coder-30b"
assert {field.key: field.required for field in linkrra.credential_fields} == {
"api_base": False,
"api_key": True,
}
@pytest.mark.asyncio
async def test_linkrra_is_listed_only_under_the_endpoints_it_serves():
from litellm.proxy.public_endpoints.public_endpoints import get_supported_endpoints
supported: Final = await get_supported_endpoints()
listed_under: Final = {
entry["key"]
for entry in supported.model_dump()["endpoints"]
if "linkrra" in {provider["slug"] for provider in entry["providers"]}
}
assert listed_under == {"chat_completions", "messages"}
def test_linkrra_chat_completion_request():
with respx.mock() as upstream:
route: Final = upstream.post(f"{_API_BASE}/chat/completions").respond(200, json=_CHAT_COMPLETION)
response: Final = litellm.completion(
model="linkrra/qwen3-coder-30b",
messages=[{"role": "user", "content": "Say hello"}],
api_key="linkrra-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == f"{_API_BASE}/chat/completions"
assert request.headers["authorization"] == "Bearer linkrra-test-key"
assert body["model"] == "qwen3-coder-30b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response.choices[0].message.content == "Hello from Linkrra"
def test_linkrra_responses_request_is_bridged_to_chat_completions():
with respx.mock() as upstream:
route: Final = upstream.post(f"{_API_BASE}/chat/completions").respond(200, json=_CHAT_COMPLETION)
response: Final = litellm.responses(
model="linkrra/qwen3-coder-30b",
input="Say hello",
api_key="linkrra-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == f"{_API_BASE}/chat/completions"
assert request.headers["authorization"] == "Bearer linkrra-test-key"
assert body["model"] == "qwen3-coder-30b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response.output[0].content[0].text == "Hello from Linkrra"
@pytest.mark.asyncio
async def test_linkrra_anthropic_messages_request_is_sent_natively(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(f"{_API_BASE}/messages").respond(
200,
json={
"id": "msg_linkrra",
"type": "message",
"role": "assistant",
"model": "qwen3-coder-30b",
"content": [{"type": "text", "text": "Hello from Linkrra"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"usage": {"input_tokens": 4, "output_tokens": 3},
},
)
response: Final = await litellm.anthropic.messages.acreate(
model="linkrra/qwen3-coder-30b",
messages=[{"role": "user", "content": "Say hello"}],
max_tokens=32,
api_key="linkrra-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == f"{_API_BASE}/messages"
assert request.headers["authorization"] == "Bearer linkrra-test-key"
assert body["model"] == "qwen3-coder-30b"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert body["max_tokens"] == 32
assert response["content"][0]["text"] == "Hello from Linkrra"