Skip to main content
Hugging Face Inference Providers routes model calls across hosted providers through a unified API, including an OpenAI-compatible endpoint at https://router.huggingface.co/v1. Use the OpenAI Python client with your Hugging Face token and Arize AX 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.

Prerequisites

  • Python 3.9+
  • An Arize AX account (sign up)
  • A Hugging Face token with Inference Providers access

Launch Arize

  1. Sign in to your Arize AX account.
  2. From Space Settings, copy your Space ID and API Key. You will set them as ARIZE_SPACE_ID and ARIZE_API_KEY below.

Install

Configure credentials

Setup tracing

Run Hugging Face Inference Providers

Expected output

Verify in Arize

  1. Open your Arize AX space and select project hugging-face-inference-providers-tracing-example.
  2. You should see a new trace within ~30 seconds containing a ChatCompletion LLM span with prompt, response, model, token, and latency metadata.
  3. 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.
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_ID and ARIZE_API_KEY are set in the same shell that runs example.py.
  • Hugging Face spans missing but other spans present. OpenAIInstrumentor().instrument(...) must run before any import openai.
  • 401 from Hugging Face. Use your Hugging Face token, not your OpenAI or Arize API 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.

Resources

Hugging Face Inference Providers

OpenInference OpenAI Instrumentor

LLM Evaluation Guide

Agent Evaluation Guide