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]

Add web search tests

Sameer Kankute11c2160379f5
diff --git a/tests/llm_translation/test_xai.py b/tests/llm_translation/test_xai.py
index aa0c33cfe05..c71b9e3fe51 100644
--- a/tests/llm_translation/test_xai.py
+++ b/tests/llm_translation/test_xai.py
@@ -177,5 +177,27 @@ class TestXAIChat(BaseLLMChatTest):
pass
def test_web_search(self):
- """xAI deprecated web search functionality"""
- pytest.skip("xAI has deprecated web search functionality")
+ """Web search is only supported for Grok 4 family models"""
+ from litellm.utils import supports_web_search
+
+ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
+ litellm.model_cost = litellm.get_model_cost_map(url="")
+
+ litellm._turn_on_debug()
+
+ # Use grok-4-1-fast which supports web search
+ model = "xai/grok-4-1-fast"
+
+ if not supports_web_search(model, None):
+ pytest.skip("Model does not support web search")
+
+ response = completion(
+ model=model,
+ messages=[
+ {"role": "user", "content": "What's the weather like in Boston today?"}
+ ],
+ web_search_options={},
+ max_tokens=100,
+ )
+
+ assert response is not None