https://router.huggingface.co/v1. Use the OpenAI Python client with your Hugging Face token and Phoenix captures requests through openinference-instrumentation-openai.
This page instruments the OpenAI-compatible Hugging Face router. It is separate from the Hugging Face smolagents integration, which instruments agent framework spans.
Install
Setup
Add a Hugging Face token with Inference Providers access, along with your Phoenix connection details, as environment variables:register function:
Run Hugging Face Inference Providers
Observe
Now that you have tracing set up, all invocations of the OpenAI client pointed at Hugging Face Inference Providers will be streamed to your running Phoenix for observability and evaluation. Each request appears as aChatCompletion LLM span with the prompt, response, model name, token usage, and latency.
Common Issues
- No traces in Phoenix: Confirm
PHOENIX_COLLECTOR_ENDPOINT(andPHOENIX_API_KEYif your Phoenix requires one) is set in the same shell that runs your app - Hugging Face Inference Providers spans missing: Call
register()before you create the OpenAI client, and make sureopeninference-instrumentation-openaiis installed soauto_instrument=Truepicks it up 401from Hugging Face: Use a Hugging Face token with Inference Providers access, not your OpenAI key- Model not found: Replace the model with one available through Hugging Face Inference Providers. Some models require selecting a provider or accepting model terms before use
- Base URL: Ensure you’re using
https://router.huggingface.co/v1as the base URL

