Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(test_get_llm_provider.py): Minimal repro for https://github.com/BerriAI/litellm/issues/9291

Krrish Dholakiaaeec703c4e88
diff --git a/tests/local_testing/test_get_llm_provider.py b/tests/local_testing/test_get_llm_provider.py
index c3f4c15c270..5872d4ea076 100644
--- a/tests/local_testing/test_get_llm_provider.py
+++ b/tests/local_testing/test_get_llm_provider.py
@@ -216,3 +216,20 @@ def test_bedrock_invoke_anthropic():
)
assert custom_llm_provider == "bedrock"
assert model == "invoke/anthropic.claude-3-5-sonnet-20240620-v1:0"
+
+
+def test_xai_api_base():
+ args = {
+ "model": "xai/grok-2-vision-latest",
+ "custom_llm_provider": "xai",
+ "api_base": None,
+ "api_key": "xai-my-specialkey",
+ "litellm_params": None,
+ }
+ model, custom_llm_provider, dynamic_api_key, api_base = litellm.get_llm_provider(
+ **args
+ )
+ assert custom_llm_provider == "xai"
+ assert model == "grok-2-vision-latest"
+ assert api_base == "https://api.x.ai/v1"
+ assert dynamic_api_key == "xai-my-specialkey"