mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
Merge eeb59c8e7c into ff182c194e
This commit is contained in:
commit
eaf1a67ff7
9 changed files with 492 additions and 0 deletions
|
|
@ -1095,6 +1095,7 @@ openai_compatible_endpoints: Final[list[str]] = [
|
|||
"https://gigachat.devices.sberbank.ru/api/v1",
|
||||
"https://api.openinfer.ai/v1",
|
||||
"https://vanchin.streamlake.ai/api/gateway/v1/endpoints",
|
||||
"https://api.runcrate.ai/v1",
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -1179,6 +1180,7 @@ openai_compatible_providers: Final[list[str]] = [
|
|||
"sail",
|
||||
"reka",
|
||||
"streamlake",
|
||||
"runcrate",
|
||||
]
|
||||
|
||||
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))
|
||||
|
|
|
|||
|
|
@ -302,5 +302,10 @@
|
|||
"preserve_cache_control": true
|
||||
},
|
||||
"supported_endpoints": ["/v1/chat/completions"]
|
||||
},
|
||||
"runcrate": {
|
||||
"base_url": "https://api.runcrate.ai/v1",
|
||||
"api_key_env": "RUNCRATE_API_KEY",
|
||||
"api_base_env": "RUNCRATE_API_BASE"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81783,5 +81783,103 @@
|
|||
"supports_response_schema": true,
|
||||
"supports_vision": true,
|
||||
"supports_xhigh_reasoning_effort": true
|
||||
},
|
||||
"runcrate/deepseek-ai/DeepSeek-V3.2": {
|
||||
"input_cost_per_token": 2.73e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 163840,
|
||||
"max_output_tokens": 147456,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 3.99e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/deepseek-ai/DeepSeek-V4.1-Flash": {
|
||||
"input_cost_per_token": 1.47e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 4.41e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"runcrate/moonshotai/Kimi-K2.6": {
|
||||
"input_cost_per_token": 7.875e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 3.675e-06,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"runcrate/openai/gpt-oss-120b": {
|
||||
"input_cost_per_token": 3.885e-08,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 117964,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.785e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/Qwen/Qwen3.8-Flash": {
|
||||
"input_cost_per_token": 1.1865e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1000000,
|
||||
"max_output_tokens": 1000000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 4.011e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/zai-org/GLM-5.3": {
|
||||
"input_cost_per_token": 5.90625e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 2.625e-06,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/zai-org/GLM-5.3-Flash": {
|
||||
"input_cost_per_token": 1.575e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 5.25e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3760,6 +3760,32 @@
|
|||
"generateContent": true
|
||||
}
|
||||
},
|
||||
"runcrate": {
|
||||
"display_name": "Runcrate (`runcrate`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/runcrate",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"responses": true,
|
||||
"text_completion": true,
|
||||
"embeddings": false,
|
||||
"image_generations": false,
|
||||
"image_edits": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"rerank": false,
|
||||
"ocr": false,
|
||||
"search": false,
|
||||
"moderations": false,
|
||||
"realtime": false,
|
||||
"video_generations": false,
|
||||
"batches": false,
|
||||
"messages": true,
|
||||
"interactions": true,
|
||||
"systemone": false,
|
||||
"a2a": true,
|
||||
"generateContent": true
|
||||
}
|
||||
},
|
||||
"snowflake": {
|
||||
"display_name": "Snowflake (`snowflake`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/snowflake",
|
||||
|
|
|
|||
|
|
@ -3715,6 +3715,34 @@
|
|||
],
|
||||
"default_model_placeholder": "streamlake/<model-or-endpoint>"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -4756,6 +4756,7 @@ class LlmProviders(str, Enum):
|
|||
SAIL = "sail"
|
||||
REKA = "reka"
|
||||
STREAMLAKE = "streamlake"
|
||||
RUNCRATE = "runcrate"
|
||||
LITELLM_AGENT = "litellm_agent"
|
||||
CURSOR = "cursor"
|
||||
BEDROCK_MANTLE = "bedrock_mantle"
|
||||
|
|
|
|||
|
|
@ -81783,5 +81783,103 @@
|
|||
"supports_response_schema": true,
|
||||
"supports_vision": true,
|
||||
"supports_xhigh_reasoning_effort": true
|
||||
},
|
||||
"runcrate/deepseek-ai/DeepSeek-V3.2": {
|
||||
"input_cost_per_token": 2.73e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 163840,
|
||||
"max_output_tokens": 147456,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 3.99e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/deepseek-ai/DeepSeek-V4.1-Flash": {
|
||||
"input_cost_per_token": 1.47e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 4.41e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"runcrate/moonshotai/Kimi-K2.6": {
|
||||
"input_cost_per_token": 7.875e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 262144,
|
||||
"max_output_tokens": 16384,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 3.675e-06,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
},
|
||||
"runcrate/openai/gpt-oss-120b": {
|
||||
"input_cost_per_token": 3.885e-08,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 131072,
|
||||
"max_output_tokens": 117964,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 1.785e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/Qwen/Qwen3.8-Flash": {
|
||||
"input_cost_per_token": 1.1865e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1000000,
|
||||
"max_output_tokens": 1000000,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 4.011e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/zai-org/GLM-5.3": {
|
||||
"input_cost_per_token": 5.90625e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 2.625e-06,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": false
|
||||
},
|
||||
"runcrate/zai-org/GLM-5.3-Flash": {
|
||||
"input_cost_per_token": 1.575e-07,
|
||||
"litellm_provider": "runcrate",
|
||||
"max_input_tokens": 1048576,
|
||||
"max_output_tokens": 1048576,
|
||||
"mode": "chat",
|
||||
"output_cost_per_token": 5.25e-07,
|
||||
"source": "https://www.runcrate.ai/inference/pricing",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3760,6 +3760,32 @@
|
|||
"generateContent": true
|
||||
}
|
||||
},
|
||||
"runcrate": {
|
||||
"display_name": "Runcrate (`runcrate`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/runcrate",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"responses": true,
|
||||
"text_completion": true,
|
||||
"embeddings": false,
|
||||
"image_generations": false,
|
||||
"image_edits": false,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"rerank": false,
|
||||
"ocr": false,
|
||||
"search": false,
|
||||
"moderations": false,
|
||||
"realtime": false,
|
||||
"video_generations": false,
|
||||
"batches": false,
|
||||
"messages": true,
|
||||
"interactions": true,
|
||||
"systemone": false,
|
||||
"a2a": true,
|
||||
"generateContent": true
|
||||
}
|
||||
},
|
||||
"snowflake": {
|
||||
"display_name": "Snowflake (`snowflake`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/snowflake",
|
||||
|
|
|
|||
208
tests/unit/llms/openai_like/test_runcrate_provider.py
Normal file
208
tests/unit/llms/openai_like/test_runcrate_provider.py
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
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():
|
||||
"""The endpoint flags are generated from the runcrate chat rows in the cost map."""
|
||||
supported: Final = {"chat_completions", "messages", "responses"}
|
||||
unsupported: Final = {
|
||||
"embeddings",
|
||||
"image_generations",
|
||||
"audio_transcriptions",
|
||||
"audio_speech",
|
||||
"moderations",
|
||||
"batches",
|
||||
"rerank",
|
||||
}
|
||||
backup_path = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json"
|
||||
root_path = Path(litellm.__file__).parent.parent / "provider_endpoints_support.json"
|
||||
|
||||
for path in (backup_path, root_path):
|
||||
endpoints = json.loads(path.read_text())["providers"]["runcrate"]["endpoints"]
|
||||
assert all(endpoints[key] for key in supported)
|
||||
assert not any(endpoints[key] for key in unsupported)
|
||||
|
||||
|
||||
def test_runcrate_cost_map_rows():
|
||||
model_cost: Final = json.loads(
|
||||
(Path(litellm.__file__).parent / "model_prices_and_context_window_backup.json").read_text()
|
||||
)
|
||||
rows: Final = {key: value for key, value in model_cost.items() if key.startswith("runcrate/")}
|
||||
assert "runcrate/deepseek-ai/DeepSeek-V3.2" in rows
|
||||
for row in rows.values():
|
||||
assert row["litellm_provider"] == "runcrate"
|
||||
assert row["mode"] == "chat"
|
||||
assert 0 < row["input_cost_per_token"] < row["output_cost_per_token"]
|
||||
|
||||
|
||||
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"
|
||||
Loading…
Add table
Reference in a new issue