https://gateway.truefoundry.ai mirrors OpenAI’s schema, so any OpenAI client works with base_url set to the gateway. Arize AX captures every gateway call via the openinference-instrumentation-openai package — the same instrumentor that covers OpenAI’s hosted API.
This guide instruments your application’s calls to the gateway. TrueFoundry can also export traces for every gateway request to Arize directly, with no application code — see the TrueFoundry platform integration.
Prerequisites
- Python 3.9+
- An Arize AX account (sign up)
- A
TRUEFOUNDRY_API_KEY— a Personal Access Token or Virtual Account Token from the Access section of TrueFoundry
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 TrueFoundry
Expected output
Verify in Arize
- Open your Arize AX space and select project
truefoundry-tracing-example. - You should see a new trace within ~30 seconds containing a
ChatCompletionLLM span with the prompt, response, and token usage attached. The model name on the span will be the resolved model the gateway routed to (e.g.gpt-4.1-mini-2025-04-14). - If no traces appear, see Troubleshooting.
Troubleshooting
- No traces in Arize. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runsexample.py. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand re-run. - TrueFoundry spans missing but other spans present.
OpenAIInstrumentor().instrument(...)must run before anyimport openai. Make sureinstrumentation.pyis the first import in your entry point. 401from TrueFoundry. Use a TrueFoundry token (Personal Access Token or Virtual Account Token from the Access section), not your OpenAI key. Pass it as theapi_key— the OpenAI client sends it as aBearertoken.- Model not found. Use the
provider-account/model-nameidentifier from your gateway (e.g.openai/gpt-4.1-mini). The prefix is the provider account name configured in your TrueFoundry workspace, not a fixed value — copy the exact model ID from the Playground Code Snippets tab.