From daf978c21eabf27a043e087f29ab2ede482f673f Mon Sep 17 00:00:00 2001 From: heydryft <48842933+heydryft@users.noreply.github.com> Date: Tue, 20 Oct 2026 19:57:09 +0100 Subject: [PATCH] feat(providers): add Runcrate as an OpenAI-compatible provider --- litellm/constants.py | 2 + litellm/llms/openai_like/providers.json | 5 + .../provider_endpoints_support_backup.json | 18 ++ .../provider_create_fields.json | 28 +++ litellm/types/utils.py | 1 + provider_endpoints_support.json | 18 ++ .../openai_like/test_runcrate_provider.py | 197 ++++++++++++++++++ 7 files changed, 269 insertions(+) create mode 100644 tests/unit/llms/openai_like/test_runcrate_provider.py diff --git a/litellm/constants.py b/litellm/constants.py index c0fe0491775..87f075309f2 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1060,6 +1060,7 @@ openai_compatible_endpoints: Final[list[str]] = [ "https://api.reka.ai/v1", "https://gigachat.devices.sberbank.ru/api/v1", "https://api.openinfer.ai/v1", + "https://api.runcrate.ai/v1", ] @@ -1138,6 +1139,7 @@ openai_compatible_providers: Final[list[str]] = [ "prism", "sail", "reka", + "runcrate", ] 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 36337fddbdc..10fd5585030 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -249,5 +249,10 @@ "/v1/responses", "/v1/messages" ] + }, + "runcrate": { + "base_url": "https://api.runcrate.ai/v1", + "api_key_env": "RUNCRATE_API_KEY", + "api_base_env": "RUNCRATE_API_BASE" } } diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index f95b553c2b4..8e77e5b2a1e 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -2207,6 +2207,24 @@ "interactions": false } }, + "runcrate": { + "display_name": "Runcrate (`runcrate`)", + "url": "https://docs.litellm.ai/docs/providers/runcrate", + "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 + } + }, "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 4bec42a7868..97fd04cda69 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -3417,6 +3417,34 @@ ], "default_model_placeholder": "inferenceapis/deepseek-ai/DeepSeek-V4-Flash" }, + { + "provider": "RUNCRATE", + "provider_display_name": "Runcrate", + "litellm_provider": "runcrate", + "credential_fields": [ + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://api.runcrate.ai/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": "runcrate/deepseek-ai/DeepSeek-V3.2" + }, { "provider": "Snowflake", "provider_display_name": "Snowflake", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 270d9b43dea..0b69c12b226 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4577,6 +4577,7 @@ class LlmProviders(str, Enum): META = "meta" SAIL = "sail" REKA = "reka" + RUNCRATE = "runcrate" LITELLM_AGENT = "litellm_agent" CURSOR = "cursor" BEDROCK_MANTLE = "bedrock_mantle" diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index d65da3f41fd..2b17b151a31 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -2479,6 +2479,24 @@ "interactions": false } }, + "runcrate": { + "display_name": "Runcrate (`runcrate`)", + "url": "https://docs.litellm.ai/docs/providers/runcrate", + "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 + } + }, "snowflake": { "display_name": "Snowflake (`snowflake`)", "url": "https://docs.litellm.ai/docs/providers/snowflake", diff --git a/tests/unit/llms/openai_like/test_runcrate_provider.py b/tests/unit/llms/openai_like/test_runcrate_provider.py new file mode 100644 index 00000000000..f01409d9d1b --- /dev/null +++ b/tests/unit/llms/openai_like/test_runcrate_provider.py @@ -0,0 +1,197 @@ +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_runcrate", + "object": "chat.completion", + "created": 1_790_000_000, + "model": "deepseek-ai/DeepSeek-V3.2", + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "Hello from Runcrate"}, + "finish_reason": "stop", + } + ], + "usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7}, +} + + +def test_runcrate_is_a_registered_provider(): + assert litellm.LlmProviders.RUNCRATE.value == "runcrate" + assert "runcrate" in litellm.provider_list + assert "runcrate" in litellm.constants.openai_compatible_providers + + +def test_runcrate_provider_resolution(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("RUNCRATE_API_KEY", "runcrate-test-key") + + model, provider, api_key, api_base = get_llm_provider( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert model == "deepseek-ai/DeepSeek-V3.2" + assert provider == "runcrate" + assert api_key == "runcrate-test-key" + assert api_base == "https://api.runcrate.ai/v1" + + +def test_runcrate_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("RUNCRATE_API_KEY", "runcrate-env-key") + monkeypatch.setenv("RUNCRATE_API_BASE", "https://runcrate.env.example/v1") + + _, provider, api_key, api_base = get_llm_provider( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + custom_llm_provider=None, + api_base="https://runcrate.internal.example/v1", + api_key="runcrate-explicit-key", + ) + + assert provider == "runcrate" + assert api_key == "runcrate-explicit-key" + assert api_base == "https://runcrate.internal.example/v1" + + +def test_runcrate_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("RUNCRATE_API_KEY", "runcrate-env-key") + monkeypatch.setenv("RUNCRATE_API_BASE", "https://runcrate.env.example/v1") + + _, provider, _, api_base = get_llm_provider( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert provider == "runcrate" + assert api_base == "https://runcrate.env.example/v1" + + +def test_runcrate_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch): + from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + + monkeypatch.setenv("RUNCRATE_API_KEY", "runcrate-env-key") + + model, provider, api_key, api_base = get_llm_provider( + model="deepseek-ai/DeepSeek-V3.2", + custom_llm_provider=None, + api_base="https://api.runcrate.ai/v1", + api_key=None, + ) + + assert model == "deepseek-ai/DeepSeek-V3.2" + assert provider == "runcrate" + assert api_key == "runcrate-env-key" + assert api_base == "https://api.runcrate.ai/v1" + + +def test_runcrate_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()) + runcrate = next(provider for provider in providers if provider["litellm_provider"] == "runcrate") + + assert runcrate["provider"] == "RUNCRATE" + assert runcrate["provider_display_name"] == "Runcrate" + assert runcrate["default_model_placeholder"] == "runcrate/deepseek-ai/DeepSeek-V3.2" + assert {field["key"]: field["required"] for field in runcrate["credential_fields"]} == { + "api_base": False, + "api_key": True, + } + + +def test_runcrate_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"]["runcrate"]["endpoints"] == expected + assert json.loads(root_path.read_text())["providers"]["runcrate"]["endpoints"] == expected + + +def test_runcrate_chat_completion_request(): + with respx.mock() as upstream: + route: Final = upstream.post("https://api.runcrate.ai/v1/chat/completions").respond(200, json=_CHAT_COMPLETION) + response: Final = litellm.completion( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + messages=[{"role": "user", "content": "Say hello"}], + api_key="runcrate-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.runcrate.ai/v1/chat/completions" + assert request.headers["authorization"] == "Bearer runcrate-test-key" + assert body["model"] == "deepseek-ai/DeepSeek-V3.2" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert response.choices[0].message.content == "Hello from Runcrate" + + +def test_runcrate_responses_request_is_bridged_to_chat_completions(): + with respx.mock() as upstream: + route: Final = upstream.post("https://api.runcrate.ai/v1/chat/completions").respond(200, json=_CHAT_COMPLETION) + response: Final = litellm.responses( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + input="Say hello", + api_key="runcrate-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer runcrate-test-key" + assert body["model"] == "deepseek-ai/DeepSeek-V3.2" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert response.output[0].content[0].text == "Hello from Runcrate" + + +@pytest.mark.asyncio +async def test_runcrate_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.runcrate.ai/v1/chat/completions").respond(200, json=_CHAT_COMPLETION) + response: Final = await litellm.anthropic.messages.acreate( + model="runcrate/deepseek-ai/DeepSeek-V3.2", + messages=[{"role": "user", "content": "Say hello"}], + max_tokens=32, + api_key="runcrate-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer runcrate-test-key" + assert body["model"] == "deepseek-ai/DeepSeek-V3.2" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert body["max_tokens"] == 32 + assert response["content"][0]["text"] == "Hello from Runcrate"