base_url to https://api.x.ai/v1 and use openinference-instrumentation-openai to send Grok traces to Arize AX.
This page instruments OpenAI SDK calls to xAI’s API. It is not a separate xAI-specific OpenInference instrumentor.
Prerequisites
- Python 3.9+
- An Arize AX account (sign up)
- An
XAI_API_KEYfrom xAI
Launch Arize
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
Setup tracing
Run xAI Grok
Expected output
Verify in Arize
- Open your Arize AX space and select project
xai-grok-tracing-example. - You should see a new trace within ~30 seconds containing a
ChatCompletionLLM span with prompt, response, model, token, and latency metadata. - If no traces appear, see Troubleshooting.
Check from the skill, CLI, or SDK
Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.- Arize skill (agent)
- AX CLI
- SDK
Install the Arize Skills plugin and let your coding agent check for you:Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.
Troubleshooting
- No traces in Arize. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.py. - xAI spans missing but other spans present.
OpenAIInstrumentor().instrument(...)must run before anyimport openai. 401from xAI. Use your xAI API key, not your OpenAI or Arize API key.- Model not found. Replace
grok-4.6with a Grok model available in your xAI account.