feat(providers): add Liquid Inference as an OpenAI-compatible provider

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
tin-chung-architect 2026-10-20 22:30:06 +07:00
parent 047cb4a8e2
commit fb1cbaa708
7 changed files with 164 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -4534,6 +4534,7 @@ class LlmProviders(str, Enum):
PRISM = "prism"
OPENINFER = "openinfer"
INFERENCEAPIS = "inferenceapis"
LIQUID = "liquid"
DARKBLOOM = "darkbloom"
META = "meta"
SAIL = "sail"

View file

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

View file

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