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(xai): narrow raises match for missing api key

kerry80b0ea6a2f46
diff --git a/tests/test_litellm/llms/xai/test_xai_audio_transcription_transformation.py b/tests/test_litellm/llms/xai/test_xai_audio_transcription_transformation.py
index f2365f00ba3..0f3445eb400 100644
--- a/tests/test_litellm/llms/xai/test_xai_audio_transcription_transformation.py
+++ b/tests/test_litellm/llms/xai/test_xai_audio_transcription_transformation.py
@@ -92,7 +92,7 @@ def test_validate_environment_sets_bearer_header():
def test_validate_environment_requires_key(monkeypatch):
monkeypatch.delenv("XAI_API_KEY", raising=False)
monkeypatch.setattr(litellm, "xai_key", None)
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="xAI API key is required"):
CONFIG.validate_environment(
headers={},
model="grok-voice-transcribe-2.0",