Portkey is an AI gateway and control panel that puts a single OpenAI-compatible endpoint in front of 250+ LLMs, with retries, fallbacks, caching, and cost controls. Arize AX captures every Portkey-routed call — the gateway request and the underlying LLM completion — via theDocumentation Index
Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
openinference-instrumentation-portkey package.
Prerequisites
- Python 3.10+
- An Arize AX account (sign up)
- A
PORTKEY_API_KEYfrom the Portkey dashboard - An
OPENAI_API_KEYfrom the OpenAI Platform (the example routes Portkey → OpenAI; swap in any other provider Portkey supports)
Launch Arize AX
- 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 Portkey
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
portkey-tracing-example. - You should see a new trace within ~30 seconds containing a
CompletionsLLM span with the prompt, response, and token usage attached. The span’sllm.model_namereflects the resolved provider model (e.g.gpt-5-mini-2025-08-07). - If no traces appear, see Troubleshooting.
Troubleshooting
- No traces in Arize AX. 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. - Portkey spans missing but other spans present.
PortkeyInstrumentor().instrument(...)must run before anyfrom portkey_ai import .... Make sureinstrumentation.pyis the first import in your entry point. 401from the gateway. A401with an OpenAI body meansOPENAI_API_KEYis invalid; a401with a Portkey body meansPORTKEY_API_KEYis invalid. Check both in the Portkey logs.- Routing to a different provider. Set
provider=increateHeaders(...)(e.g."anthropic","google") and pass the matching provider key. Portkey also supports virtual keys — see the Portkey docs for setup.