From e9a6a25fe33b9bf507e4617dbc365365c9817f35 Mon Sep 17 00:00:00 2001 From: Aditya Batra Date: Wed, 4 Nov 2026 05:51:25 +0530 Subject: [PATCH] feat(providers): add Wally as an OpenAI-compatible provider (#45662) --- litellm/__init__.py | 5 + litellm/constants.py | 2 + litellm/llms/openai_like/providers.json | 9 + ...odel_prices_and_context_window_backup.json | 310 ++++++++++++++++++ .../provider_endpoints_support_backup.json | 26 ++ .../provider_create_fields.json | 28 ++ litellm/types/utils.py | 1 + model_prices_and_context_window.json | 310 ++++++++++++++++++ provider_endpoints_support.json | 26 ++ .../llms/openai_like/test_wally_provider.py | 269 +++++++++++++++ 10 files changed, 986 insertions(+) create mode 100644 tests/unit/llms/openai_like/test_wally_provider.py diff --git a/litellm/__init__.py b/litellm/__init__.py index 102c4d1440f..297941a6649 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -688,6 +688,7 @@ darkbloom_models: Set = set() openinfer_models: Final[Set[str]] = set() kyma_models: Final[set[str]] = set() # mutable-ok: populated when the shared model catalog loads streamlake_models: Final[Set[str]] = set() +wally_models: Final[Set[str]] = set() zerogpu_models: Final[Set[str]] = set() v0_models: Set = set() morph_models: Set = set() @@ -984,6 +985,8 @@ def _populate_provider_model_sets(model_cost_map: Mapping[str, Mapping[str, obje kyma_models.add(key) elif value.get("litellm_provider") == "streamlake": streamlake_models.add(key) + elif value.get("litellm_provider") == "wally": + wally_models.add(key) elif value.get("litellm_provider") == "zerogpu": zerogpu_models.add(key) elif value.get("litellm_provider") == "v0": @@ -1166,6 +1169,7 @@ model_list = list( | openinfer_models | kyma_models | streamlake_models + | wally_models | zerogpu_models | v0_models | morph_models @@ -1299,6 +1303,7 @@ def _build_models_by_provider() -> dict: "openinfer": openinfer_models, "kyma": kyma_models, "streamlake": streamlake_models, + "wally": wally_models, "zerogpu": zerogpu_models, "v0": v0_models, "morph": morph_models, diff --git a/litellm/constants.py b/litellm/constants.py index 231e99234d8..32b47bc6b46 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -1093,6 +1093,7 @@ openai_compatible_endpoints: Final[list[str]] = [ "https://api.scx.ai/v1", "https://api.prisminference.com/v1", "https://api.reka.ai/v1", + "https://inference.runanywhere.ai/v1", "https://gigachat.devices.sberbank.ru/api/v1", "https://api.openinfer.ai/v1", "https://vanchin.streamlake.ai/api/gateway/v1/endpoints", @@ -1180,6 +1181,7 @@ openai_compatible_providers: Final[list[str]] = [ "sail", "reka", "streamlake", + "wally", ] 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 a71a9c3bb9b..c89ede6e77e 100644 --- a/litellm/llms/openai_like/providers.json +++ b/litellm/llms/openai_like/providers.json @@ -302,5 +302,14 @@ "preserve_cache_control": true }, "supported_endpoints": ["/v1/chat/completions"] + }, + "wally": { + "base_url": "https://inference.runanywhere.ai/v1", + "api_key_env": "WALLY_API_KEY", + "api_base_env": "WALLY_API_BASE", + "provider_info": { + "supports_function_calling": true, + "supports_reasoning": true + } } } diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 85bcb8f5411..9b9ddeaaaa4 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -83163,5 +83163,315 @@ "supports_reasoning": true, "supports_function_calling": true, "source": "https://tokenfactory.nebius.com/api/public/models_info" + }, + "wally/glm-5.3-flash": { + "cache_read_input_token_cost": 7.6e-08, + "input_cost_per_token": 2.72e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048567, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6.5e-07, + "reasoning_effort_levels": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash": { + "cache_read_input_token_cost": 6e-09, + "input_cost_per_token": 3e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048569, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/kimi-k3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/deepseek-v4.1-flash-fast": { + "cache_read_input_token_cost": 1.4e-08, + "input_cost_per_token": 6e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/glm-5.3-fast": { + "cache_read_input_token_cost": 3.9e-07, + "input_cost_per_token": 2.1e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6.6e-06, + "reasoning_effort_levels": [ + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4-pro-fast": { + "cache_read_input_token_cost": 1.6e-07, + "input_cost_per_token": 1.91e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.83e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4-flash-0731": { + "cache_read_input_token_cost": 1.4e-08, + "input_cost_per_token": 4.4e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.32e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/minimax-m3": { + "cache_read_input_token_cost": 6.6e-08, + "input_cost_per_token": 3.3e-07, + "litellm_provider": "wally", + "max_input_tokens": 524287, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 1.32e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash-1017": { + "cache_read_input_token_cost": 8e-09, + "input_cost_per_token": 3.75e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.5e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://inference.runanywhere.ai/v1/models", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash-f2": { + "cache_read_input_token_cost": 6e-09, + "input_cost_per_token": 3e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://inference.runanywhere.ai/v1/models", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true } } diff --git a/litellm/provider_endpoints_support_backup.json b/litellm/provider_endpoints_support_backup.json index 40ea9d15ff4..672a2739964 100644 --- a/litellm/provider_endpoints_support_backup.json +++ b/litellm/provider_endpoints_support_backup.json @@ -5250,6 +5250,32 @@ "generateContent": false } }, + "wally": { + "display_name": "Wally (`wally`)", + "url": "https://docs.litellm.ai/docs/providers/wally", + "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 + } + }, "empiriolabs": { "display_name": "EmpirioLabs (`empiriolabs`)", "url": "https://docs.litellm.ai/docs/providers/empiriolabs", diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json index aa7554c4a5a..9d4ede7b90d 100644 --- a/litellm/proxy/public_endpoints/provider_create_fields.json +++ b/litellm/proxy/public_endpoints/provider_create_fields.json @@ -3567,6 +3567,34 @@ ], "default_model_placeholder": "reka/reka-flash" }, + { + "provider": "WALLY", + "provider_display_name": "Wally", + "litellm_provider": "wally", + "credential_fields": [ + { + "key": "api_base", + "label": "API Base", + "placeholder": "https://inference.runanywhere.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": "wally/glm-5.3-flash" + }, { "provider": "Sail", "provider_display_name": "Sail", diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 46dcec429da..ee80b63f93b 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -4774,6 +4774,7 @@ class LlmProviders(str, Enum): SAIL = "sail" REKA = "reka" STREAMLAKE = "streamlake" + WALLY = "wally" LITELLM_AGENT = "litellm_agent" CURSOR = "cursor" BEDROCK_MANTLE = "bedrock_mantle" diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 85bcb8f5411..9b9ddeaaaa4 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -83163,5 +83163,315 @@ "supports_reasoning": true, "supports_function_calling": true, "source": "https://tokenfactory.nebius.com/api/public/models_info" + }, + "wally/glm-5.3-flash": { + "cache_read_input_token_cost": 7.6e-08, + "input_cost_per_token": 2.72e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048567, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6.5e-07, + "reasoning_effort_levels": [ + "minimal", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash": { + "cache_read_input_token_cost": 6e-09, + "input_cost_per_token": 3e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048569, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/kimi-k3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/deepseek-v4.1-flash-fast": { + "cache_read_input_token_cost": 1.4e-08, + "input_cost_per_token": 6e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 2.4e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true + }, + "wally/glm-5.3-fast": { + "cache_read_input_token_cost": 3.9e-07, + "input_cost_per_token": 2.1e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 6.6e-06, + "reasoning_effort_levels": [ + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4-pro-fast": { + "cache_read_input_token_cost": 1.6e-07, + "input_cost_per_token": 1.91e-06, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 3.83e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4-flash-0731": { + "cache_read_input_token_cost": 1.4e-08, + "input_cost_per_token": 4.4e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.32e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/minimax-m3": { + "cache_read_input_token_cost": 6.6e-08, + "input_cost_per_token": 3.3e-07, + "litellm_provider": "wally", + "max_input_tokens": 524287, + "max_output_tokens": 131072, + "mode": "chat", + "output_cost_per_token": 1.32e-06, + "reasoning_effort_levels": [ + "none", + "low", + "medium", + "high", + "xhigh", + "max" + ], + "source": "https://www.runwally.com/pricing", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash-1017": { + "cache_read_input_token_cost": 8e-09, + "input_cost_per_token": 3.75e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.5e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://inference.runanywhere.ai/v1/models", + "supported_modalities": [ + "text" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false + }, + "wally/deepseek-v4.1-flash-f2": { + "cache_read_input_token_cost": 6e-09, + "input_cost_per_token": 3e-07, + "litellm_provider": "wally", + "max_input_tokens": 1048576, + "max_output_tokens": 65536, + "mode": "chat", + "output_cost_per_token": 1.2e-06, + "reasoning_effort_levels": [ + "none", + "minimal", + "low", + "medium", + "high", + "max" + ], + "source": "https://inference.runanywhere.ai/v1/models", + "supported_modalities": [ + "text", + "image" + ], + "supported_output_modalities": [ + "text" + ], + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_response_schema": false, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": true } } diff --git a/provider_endpoints_support.json b/provider_endpoints_support.json index 40ea9d15ff4..672a2739964 100644 --- a/provider_endpoints_support.json +++ b/provider_endpoints_support.json @@ -5250,6 +5250,32 @@ "generateContent": false } }, + "wally": { + "display_name": "Wally (`wally`)", + "url": "https://docs.litellm.ai/docs/providers/wally", + "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 + } + }, "empiriolabs": { "display_name": "EmpirioLabs (`empiriolabs`)", "url": "https://docs.litellm.ai/docs/providers/empiriolabs", diff --git a/tests/unit/llms/openai_like/test_wally_provider.py b/tests/unit/llms/openai_like/test_wally_provider.py new file mode 100644 index 00000000000..ac730b5760f --- /dev/null +++ b/tests/unit/llms/openai_like/test_wally_provider.py @@ -0,0 +1,269 @@ +import json +from pathlib import Path +from typing import Final + +import pytest +import respx + +import litellm +from litellm.caching.llm_caching_handler import LLMClientCache +from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider + +_DEFAULT_API_BASE: Final = "https://inference.runanywhere.ai/v1" +_CHAT_COMPLETIONS_URL: Final = f"{_DEFAULT_API_BASE}/chat/completions" +_CHAT_COMPLETION: Final = { + "id": "chatcmpl_wally", + "object": "chat.completion", + "created": 1_790_000_000, + "model": "glm-5.3-flash", + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "Hello from Wally", "reasoning_content": "Say hi"}, + "finish_reason": "stop", + } + ], + "usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7}, +} +_EXPECTED_ENDPOINTS: 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, +} +WALLY_MODELS: Final = tuple(sorted(name for name in litellm.model_cost if name.startswith("wally/"))) + + +def test_wally_is_a_registered_provider(): + assert litellm.LlmProviders.WALLY.value == "wally" + assert "wally" in litellm.provider_list + assert "wally" in litellm.constants.openai_compatible_providers + assert _DEFAULT_API_BASE in litellm.constants.openai_compatible_endpoints + + +def test_wally_provider_resolution(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("WALLY_API_KEY", "wally-test-key") + monkeypatch.delenv("WALLY_API_BASE", raising=False) + + model, provider, api_key, api_base = get_llm_provider( + model="wally/glm-5.3-flash", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert model == "glm-5.3-flash" + assert provider == "wally" + assert api_key == "wally-test-key" + assert api_base == _DEFAULT_API_BASE + + +def test_wally_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("WALLY_API_KEY", "wally-env-key") + monkeypatch.setenv("WALLY_API_BASE", "https://wally.env.example/v1") + + _, provider, api_key, api_base = get_llm_provider( + model="wally/glm-5.3-flash", + custom_llm_provider=None, + api_base="https://wally.internal.example/v1", + api_key="wally-explicit-key", + ) + + assert provider == "wally" + assert api_key == "wally-explicit-key" + assert api_base == "https://wally.internal.example/v1" + + +def test_wally_api_base_env_overrides_default(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("WALLY_API_KEY", "wally-env-key") + monkeypatch.setenv("WALLY_API_BASE", "https://wally.env.example/v1") + + _, provider, _, api_base = get_llm_provider( + model="wally/glm-5.3-flash", + custom_llm_provider=None, + api_base=None, + api_key=None, + ) + + assert provider == "wally" + assert api_base == "https://wally.env.example/v1" + + +def test_wally_api_base_autodetects_provider(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setenv("WALLY_API_KEY", "wally-env-key") + + model, provider, api_key, api_base = get_llm_provider( + model="glm-5.3-flash", + custom_llm_provider=None, + api_base=_DEFAULT_API_BASE, + api_key=None, + ) + + assert model == "glm-5.3-flash" + assert provider == "wally" + assert api_key == "wally-env-key" + assert api_base == _DEFAULT_API_BASE + + +@pytest.mark.parametrize("model", WALLY_MODELS) +def test_wally_model_cost_and_capabilities(model: str): + from litellm.cost_calculator import cost_per_token + from litellm.utils import ( + supports_function_calling, + supports_prompt_caching, + supports_reasoning, + supports_response_schema, + supports_tool_choice, + supports_vision, + ) + + entry: Final = litellm.model_cost[model] + prompt_cost, completion_cost = cost_per_token( + model=model, + prompt_tokens=1_000_000, + completion_tokens=1_000_000, + custom_llm_provider="wally", + ) + cached_prompt_cost, _ = cost_per_token( + model=model, + prompt_tokens=1_000_000, + completion_tokens=0, + cache_read_input_tokens=1_000_000, + custom_llm_provider="wally", + ) + model_info: Final = litellm.get_model_info(model) + + assert prompt_cost == pytest.approx(entry["input_cost_per_token"] * 1_000_000) + assert completion_cost == pytest.approx(entry["output_cost_per_token"] * 1_000_000) + assert cached_prompt_cost == pytest.approx(entry["cache_read_input_token_cost"] * 1_000_000) + assert model_info["max_tokens"] == entry["max_output_tokens"] + assert model_info["litellm_provider"] == "wally" + assert supports_function_calling(model) is entry["supports_function_calling"] + assert supports_tool_choice(model) is entry["supports_tool_choice"] + assert supports_reasoning(model) is entry["supports_reasoning"] + assert supports_prompt_caching(model) is entry["supports_prompt_caching"] + assert supports_response_schema(model) is entry["supports_response_schema"] + assert supports_vision(model) is ("image" in entry["supported_modalities"]) + + +@pytest.mark.usefixtures("local_model_cost_map") +def test_wally_wildcard_expands_to_every_wally_row(): + from litellm.proxy.auth.model_checks import get_known_models_from_wildcard + + assert set(get_known_models_from_wildcard("wally/*")) == set(WALLY_MODELS) + + +def test_wally_model_missing_from_cost_map_uses_provider_defaults(): + from litellm.utils import supports_function_calling, supports_reasoning + + assert supports_function_calling("wally/a-model-not-in-the-cost-map") is True + assert supports_reasoning("wally/a-model-not-in-the-cost-map") is True + + +def test_wally_backup_registry_mirrors_cost_map(): + package_root: Final = Path(litellm.__file__).parent + cost_map: Final = json.loads((package_root.parent / "model_prices_and_context_window.json").read_text()) + backup: Final = json.loads((package_root / "model_prices_and_context_window_backup.json").read_text()) + wally_entries: Final = {name: entry for name, entry in cost_map.items() if name.startswith("wally/")} + + assert wally_entries + assert tuple(sorted(wally_entries)) == WALLY_MODELS + assert wally_entries == {name: backup[name] for name in wally_entries} + + +def test_wally_is_available_in_add_model_form(): + fields_path: Final = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json" + providers: Final = json.loads(fields_path.read_text()) + wally: Final = next(provider for provider in providers if provider["litellm_provider"] == "wally") + + assert wally["provider"] == "WALLY" + assert wally["provider_display_name"] == "Wally" + assert wally["default_model_placeholder"] in WALLY_MODELS + assert {field["key"]: field["required"] for field in wally["credential_fields"]} == { + "api_base": False, + "api_key": True, + } + + +def test_wally_supported_endpoints(): + backup_path: Final = Path(litellm.__file__).parent / "provider_endpoints_support_backup.json" + root_path: Final = Path(litellm.__file__).parent.parent / "provider_endpoints_support.json" + + backup: Final = json.loads(backup_path.read_text())["providers"]["wally"]["endpoints"] + root: Final = json.loads(root_path.read_text())["providers"]["wally"]["endpoints"] + + assert backup == root + assert {endpoint: root[endpoint] for endpoint in _EXPECTED_ENDPOINTS} == _EXPECTED_ENDPOINTS + + +@pytest.mark.parametrize("reasoning_effort", ["none", "max"]) +def test_wally_chat_completion_request(reasoning_effort: str): + with respx.mock() as upstream: + route: Final = upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=_CHAT_COMPLETION) + response: Final = litellm.completion( + model="wally/glm-5.3-flash", + messages=[{"role": "user", "content": "Say hello"}], + max_completion_tokens=64, + reasoning_effort=reasoning_effort, + api_key="wally-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert str(request.url) == _CHAT_COMPLETIONS_URL + assert request.headers["authorization"] == "Bearer wally-test-key" + assert body["model"] == "glm-5.3-flash" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert body["max_completion_tokens"] == 64 + assert body["reasoning_effort"] == reasoning_effort + assert response.choices[0].message.content == "Hello from Wally" + assert response.choices[0].message.reasoning_content == "Say hi" + + +def test_wally_responses_request_is_bridged_to_chat_completions(): + with respx.mock() as upstream: + route: Final = upstream.post(_CHAT_COMPLETIONS_URL).respond(200, json=_CHAT_COMPLETION) + response: Final = litellm.responses( + model="wally/glm-5.3-flash", + input="Say hello", + api_key="wally-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer wally-test-key" + assert body["model"] == "glm-5.3-flash" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + message_items: Final = [item for item in response.output if item.type == "message"] + assert message_items[0].content[0].text == "Hello from Wally" + + +@pytest.mark.asyncio +async def test_wally_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(_CHAT_COMPLETIONS_URL).respond(200, json=_CHAT_COMPLETION) + response: Final = await litellm.anthropic.messages.acreate( + model="wally/glm-5.3-flash", + messages=[{"role": "user", "content": "Say hello"}], + max_tokens=32, + api_key="wally-test-key", + ) + + request: Final = route.calls.last.request + body: Final = json.loads(request.content) + assert route.call_count == 1 + assert request.headers["authorization"] == "Bearer wally-test-key" + assert body["model"] == "glm-5.3-flash" + assert body["messages"] == [{"role": "user", "content": "Say hello"}] + assert body["max_tokens"] == 32 + assert any(block.get("text") == "Hello from Wally" for block in response["content"])