base_url to https://api.x.ai/v1 and use openinference-instrumentation-openai to send Grok traces to Phoenix.
This page instruments OpenAI SDK calls to xAI’s API. It is not a separate xAI-specific OpenInference instrumentor.
Install
Setup
Add your xAI API key as an environment variable:register function:
Run xAI Grok
Observe
Now that you have tracing set up, all invocations of the OpenAI client pointed at xAI Grok will be streamed to your running Phoenix for observability and evaluation. Each call appears as aChatCompletion LLM span with the prompt, response, model name, token usage, and latency.
Common Issues
- Spans missing:
register(..., auto_instrument=True)must run before your application sends requests, andopeninference-instrumentation-openaimust be installed in the same environment 401from xAI: Use your xAI API key, not an OpenAI key- Model not found: Replace
grok-4.6with a Grok model available in your xAI account - Base URL: Ensure you’re using
https://api.x.ai/v1as the base URL

