mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-27 06:13:07 +00:00
feat(providers): add RainDragon as an OpenAI-compatible provider
RainDragon (https://raindragon.ai) serves Gemma 4 26B and 31B through an OpenAI-compatible API at https://inference.raindragon.ai/v1. Adds the raindragon provider to providers.json (RAINDRAGON_API_KEY, RAINDRAGON_API_BASE), registers it as OpenAI-compatible, lists its endpoint support and the proxy add-model form entry, following the Reka provider.
This commit is contained in:
parent
d5ce7dbb8c
commit
554ab0613b
7 changed files with 275 additions and 0 deletions
|
|
@ -1023,6 +1023,7 @@ openai_compatible_endpoints: Final[list[str]] = [
|
|||
"https://api.scx.ai/v1",
|
||||
"https://api.prisminference.com/v1",
|
||||
"https://api.reka.ai/v1",
|
||||
"https://inference.raindragon.ai/v1",
|
||||
"https://gigachat.devices.sberbank.ru/api/v1",
|
||||
]
|
||||
|
||||
|
|
@ -1101,6 +1102,7 @@ openai_compatible_providers: Final[list] = [
|
|||
"prism",
|
||||
"sail",
|
||||
"reka",
|
||||
"raindragon",
|
||||
]
|
||||
|
||||
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))
|
||||
|
|
|
|||
|
|
@ -239,5 +239,10 @@
|
|||
"/v1/responses",
|
||||
"/v1/messages"
|
||||
]
|
||||
},
|
||||
"raindragon": {
|
||||
"base_url": "https://inference.raindragon.ai/v1",
|
||||
"api_key_env": "RAINDRAGON_API_KEY",
|
||||
"api_base_env": "RAINDRAGON_API_BASE"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2154,6 +2154,24 @@
|
|||
"interactions": false
|
||||
}
|
||||
},
|
||||
"raindragon": {
|
||||
"display_name": "RainDragon (`raindragon`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/raindragon",
|
||||
"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
|
||||
}
|
||||
},
|
||||
"scaleway": {
|
||||
"display_name": "Scaleway (`scaleway`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/scaleway",
|
||||
|
|
|
|||
|
|
@ -3231,6 +3231,34 @@
|
|||
],
|
||||
"default_model_placeholder": "reka/reka-flash"
|
||||
},
|
||||
{
|
||||
"provider": "RAINDRAGON",
|
||||
"provider_display_name": "RainDragon",
|
||||
"litellm_provider": "raindragon",
|
||||
"credential_fields": [
|
||||
{
|
||||
"key": "api_base",
|
||||
"label": "API Base",
|
||||
"placeholder": "https://inference.raindragon.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": "raindragon/google/gemma-4-26B-A4B-it"
|
||||
},
|
||||
{
|
||||
"provider": "Sail",
|
||||
"provider_display_name": "Sail",
|
||||
|
|
|
|||
|
|
@ -4389,6 +4389,7 @@ class LlmProviders(str, Enum):
|
|||
META = "meta"
|
||||
SAIL = "sail"
|
||||
REKA = "reka"
|
||||
RAINDRAGON = "raindragon"
|
||||
LITELLM_AGENT = "litellm_agent"
|
||||
CURSOR = "cursor"
|
||||
BEDROCK_MANTLE = "bedrock_mantle"
|
||||
|
|
|
|||
|
|
@ -3214,6 +3214,24 @@
|
|||
"interactions": false
|
||||
}
|
||||
},
|
||||
"raindragon": {
|
||||
"display_name": "RainDragon (`raindragon`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/raindragon",
|
||||
"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
|
||||
}
|
||||
},
|
||||
"charity_engine": {
|
||||
"display_name": "Charity Engine (`charity_engine`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/charity_engine",
|
||||
|
|
|
|||
203
tests/unit/llms/openai_like/test_raindragon_provider.py
Normal file
203
tests/unit/llms/openai_like/test_raindragon_provider.py
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
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_raindragon",
|
||||
"object": "chat.completion",
|
||||
"created": 1_790_000_000,
|
||||
"model": "google/gemma-4-26B-A4B-it",
|
||||
"choices": [
|
||||
{
|
||||
"index": 0,
|
||||
"message": {"role": "assistant", "content": "Hello from RainDragon"},
|
||||
"finish_reason": "stop",
|
||||
}
|
||||
],
|
||||
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
|
||||
}
|
||||
|
||||
|
||||
def test_raindragon_is_a_registered_provider():
|
||||
assert litellm.LlmProviders.RAINDRAGON.value == "raindragon"
|
||||
assert "raindragon" in litellm.provider_list
|
||||
assert "raindragon" in litellm.constants.openai_compatible_providers
|
||||
|
||||
|
||||
def test_raindragon_provider_resolution(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("RAINDRAGON_API_KEY", "raindragon-test-key")
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "google/gemma-4-26B-A4B-it"
|
||||
assert provider == "raindragon"
|
||||
assert api_key == "raindragon-test-key"
|
||||
assert api_base == "https://inference.raindragon.ai/v1"
|
||||
|
||||
|
||||
def test_raindragon_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("RAINDRAGON_API_KEY", "raindragon-env-key")
|
||||
monkeypatch.setenv("RAINDRAGON_API_BASE", "https://raindragon.env.example/v1")
|
||||
|
||||
_, provider, api_key, api_base = get_llm_provider(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://raindragon.internal.example/v1",
|
||||
api_key="raindragon-explicit-key",
|
||||
)
|
||||
|
||||
assert provider == "raindragon"
|
||||
assert api_key == "raindragon-explicit-key"
|
||||
assert api_base == "https://raindragon.internal.example/v1"
|
||||
|
||||
|
||||
def test_raindragon_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("RAINDRAGON_API_KEY", "raindragon-env-key")
|
||||
monkeypatch.setenv("RAINDRAGON_API_BASE", "https://raindragon.env.example/v1")
|
||||
|
||||
_, provider, _, api_base = get_llm_provider(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
custom_llm_provider=None,
|
||||
api_base=None,
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert provider == "raindragon"
|
||||
assert api_base == "https://raindragon.env.example/v1"
|
||||
|
||||
|
||||
def test_raindragon_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch):
|
||||
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
|
||||
|
||||
monkeypatch.setenv("RAINDRAGON_API_KEY", "raindragon-env-key")
|
||||
|
||||
model, provider, api_key, api_base = get_llm_provider(
|
||||
model="google/gemma-4-26B-A4B-it",
|
||||
custom_llm_provider=None,
|
||||
api_base="https://inference.raindragon.ai/v1",
|
||||
api_key=None,
|
||||
)
|
||||
|
||||
assert model == "google/gemma-4-26B-A4B-it"
|
||||
assert provider == "raindragon"
|
||||
assert api_key == "raindragon-env-key"
|
||||
assert api_base == "https://inference.raindragon.ai/v1"
|
||||
|
||||
|
||||
def test_raindragon_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())
|
||||
raindragon = next(provider for provider in providers if provider["litellm_provider"] == "raindragon")
|
||||
|
||||
assert raindragon["provider"] == "RAINDRAGON"
|
||||
assert raindragon["provider_display_name"] == "RainDragon"
|
||||
assert raindragon["default_model_placeholder"] == "raindragon/google/gemma-4-26B-A4B-it"
|
||||
assert {field["key"]: field["required"] for field in raindragon["credential_fields"]} == {
|
||||
"api_base": False,
|
||||
"api_key": True,
|
||||
}
|
||||
|
||||
|
||||
def test_raindragon_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"]["raindragon"]["endpoints"] == expected
|
||||
assert json.loads(root_path.read_text())["providers"]["raindragon"]["endpoints"] == expected
|
||||
|
||||
|
||||
def test_raindragon_chat_completion_request():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://inference.raindragon.ai/v1/chat/completions").respond(
|
||||
200, json=_CHAT_COMPLETION
|
||||
)
|
||||
response: Final = litellm.completion(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
api_key="raindragon-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert str(request.url) == "https://inference.raindragon.ai/v1/chat/completions"
|
||||
assert request.headers["authorization"] == "Bearer raindragon-test-key"
|
||||
assert body["model"] == "google/gemma-4-26B-A4B-it"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert response.choices[0].message.content == "Hello from RainDragon"
|
||||
|
||||
|
||||
def test_raindragon_responses_request_is_bridged_to_chat_completions():
|
||||
with respx.mock() as upstream:
|
||||
route: Final = upstream.post("https://inference.raindragon.ai/v1/chat/completions").respond(
|
||||
200, json=_CHAT_COMPLETION
|
||||
)
|
||||
response: Final = litellm.responses(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
input="Say hello",
|
||||
api_key="raindragon-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer raindragon-test-key"
|
||||
assert body["model"] == "google/gemma-4-26B-A4B-it"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert response.output[0].content[0].text == "Hello from RainDragon"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_raindragon_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://inference.raindragon.ai/v1/chat/completions").respond(
|
||||
200, json=_CHAT_COMPLETION
|
||||
)
|
||||
response: Final = await litellm.anthropic.messages.acreate(
|
||||
model="raindragon/google/gemma-4-26B-A4B-it",
|
||||
messages=[{"role": "user", "content": "Say hello"}],
|
||||
max_tokens=32,
|
||||
api_key="raindragon-test-key",
|
||||
)
|
||||
|
||||
request: Final = route.calls.last.request
|
||||
body: Final = json.loads(request.content)
|
||||
assert route.call_count == 1
|
||||
assert request.headers["authorization"] == "Bearer raindragon-test-key"
|
||||
assert body["model"] == "google/gemma-4-26B-A4B-it"
|
||||
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
|
||||
assert body["max_tokens"] == 32
|
||||
assert response["content"][0]["text"] == "Hello from RainDragon"
|
||||
Loading…
Add table
Reference in a new issue