From fb1cbaa708205f5852f17f78774cea2f229d7318 Mon Sep 17 00:00:00 2001 From: tin-chung-architect Date: Tue, 20 Oct 2026 22:30:06 +0700 Subject: [PATCH] feat(providers): add Liquid Inference as an OpenAI-compatible provider Co-Authored-By: Claude Sonnet 5.5 --- litellm/constants.py | 1 + litellm/llms/openai_like/providers.json | 10 +++ .../provider_endpoints_support_backup.json | 18 ++++ .../provider_create_fields.json | 28 ++++++ litellm/types/utils.py | 1 + provider_endpoints_support.json | 18 ++++ .../llms/openai_like/test_liquid_provider.py | 88 +++++++++++++++++++ 7 files changed, 164 insertions(+) create mode 100644 tests/unit/llms/openai_like/test_liquid_provider.py diff --git a/litellm/constants.py b/litellm/constants.py index bc94760b187..7648c8c143c 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1164,6 +1164,7 @@ _openai_like_providers: Final[list[str]] = [ "lemonade", "watsonx", "inferenceapis", + "liquid", ] # private helper. similar to openai but require some custom auth / endpoint handling, so can't use the openai sdk # well supported replicate llms replicate_models: Final[set] = set( diff --git a/litellm/llms/openai_like/providers.json b/litellm/llms/openai_like/providers.json index 36337fddbdc..f3851e5672d 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -249,5 +249,15 @@ "/v1/responses", "/v1/messages" ] + }, + "liquid": { + "base_url": "https://router.inference.ai.exchange/v1", + "api_key_env": "LIQUID_API_KEY", + "api_base_env": "LIQUID_API_BASE", + "supported_endpoints": [ + "/v1/chat/completions", + "/v1/responses", + "/v1/messages" + ] } } diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index f95b553c2b4..8d83b4a63bd 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -2207,6 +2207,24 @@ "interactions": false } }, + "liquid": { + "display_name": "Liquid Inference (`liquid`)", + "url": "https://docs.litellm.ai/docs/providers/liquid", + "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 a794854ce19..8044aaa917b 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -3407,6 +3407,34 @@ ], "default_model_placeholder": "inferenceapis/deepseek-ai/DeepSeek-V4-Flash" }, + { + "provider": "LIQUID", + "provider_display_name": "Liquid Inference", + "litellm_provider": "liquid", + "credential_fields": [ + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://router.inference.ai.exchange/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": "liquid/liquid.auto" + }, { "provider": "Snowflake", "provider_display_name": "Snowflake", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 2721a0c1cc1..c81b3c39b36 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4534,6 +4534,7 @@ class LlmProviders(str, Enum): PRISM = "prism" OPENINFER = "openinfer" INFERENCEAPIS = "inferenceapis" + LIQUID = "liquid" DARKBLOOM = "darkbloom" META = "meta" SAIL = "sail" diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index d65da3f41fd..cb089d9d82c 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -2479,6 +2479,24 @@ "interactions": false } }, + "liquid": { + "display_name": "Liquid Inference (`liquid`)", + "url": "https://docs.litellm.ai/docs/providers/liquid", + "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_liquid_provider.py b/tests/unit/llms/openai_like/test_liquid_provider.py new file mode 100644 index 00000000000..36210b232db --- /dev/null +++ b/tests/unit/llms/openai_like/test_liquid_provider.py @@ -0,0 +1,88 @@ +import json +from typing import Final + +import httpx +import pytest +import respx + +import litellm +from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider +from litellm.llms.openai_like.json_loader import JSONProviderRegistry + +LIQUID_API_BASE: Final = "https://router.inference.ai.exchange/v1" +LIQUID_MODEL_ID: Final = "liquid.auto" +LIQUID_MODEL: Final = f"liquid/{LIQUID_MODEL_ID}" + + +def _chat_completion_body() -> dict[str, object]: + return { + "id": "chatcmpl_liquid", + "object": "chat.completion", + "created": 1_789_550_000, + "model": LIQUID_MODEL_ID, + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "Hello from Liquid"}, + "finish_reason": "stop", + } + ], + "usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7}, + } + + +def test_liquid_provider_is_registered_with_its_endpoints(): + provider: Final = JSONProviderRegistry.get("liquid") + + assert provider is not None + assert provider.base_url == LIQUID_API_BASE + assert set(provider.supported_endpoints) == {"/v1/chat/completions", "/v1/responses", "/v1/messages"} + + +def test_liquid_provider_resolution(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("LIQUID_API_KEY", "liquid-env-key") + + model, provider, api_key, api_base = get_llm_provider( + model=LIQUID_MODEL, + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert model == LIQUID_MODEL_ID + assert provider == "liquid" + assert api_key == "liquid-env-key" + assert api_base == LIQUID_API_BASE + + +def test_liquid_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("LIQUID_API_KEY", "liquid-env-key") + + _, provider, api_key, api_base = get_llm_provider( + model=LIQUID_MODEL, + custom_llm_provider=None, + api_base="https://liquid.internal.example/v1", + api_key="liquid-explicit-key", + ) + + assert provider == "liquid" + assert api_key == "liquid-explicit-key" + assert api_base == "https://liquid.internal.example/v1" + + +def test_liquid_chat_completion_request(): + with respx.mock() as upstream: + route: Final = upstream.post(f"{LIQUID_API_BASE}/chat/completions").respond(200, json=_chat_completion_body()) + response: Final = litellm.completion( + model=LIQUID_MODEL, + messages=[{"role": "user", "content": "Say hello"}], + api_key="liquid-test-key", + ) + + request: Final[httpx.Request] = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer liquid-test-key" + assert body["model"] == LIQUID_MODEL_ID + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert response.choices[0].message.content == "Hello from Liquid"