Skip to main content
To trace OpenAI with HoneyHive, install honeyhive[openinference-openai], call HoneyHiveTracer.init(), run OpenAIInstrumentor().instrument(tracer_provider=tracer.provider), and use your existing OpenAI client unchanged. See the tracing quickstart and tracer initialization guides for setup details. OpenAI provides GPT models for chat completions, embeddings, and more. HoneyHive integrates with OpenAI via the OpenInference instrumentor, automatically capturing all API calls, tool use, and token usage.

How do I trace OpenAI with HoneyHive?

Add HoneyHive tracing in just 4 lines of code. Add this to your existing OpenAI app and all chat completions, tool calls, and embeddings are automatically traced.
To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see Tracer Initialization.
Last tested with openai 2.30.0 (April 2026).

What Gets Traced

The instrumentor automatically captures:
  • Chat completions - client.chat.completions.create() with inputs, outputs, and token usage
  • Tool / function calls - Each tool call with arguments and results
  • Embeddings - client.embeddings.create() requests
  • Streaming responses - Streamed completions with aggregated tokens
No manual instrumentation required.

Example: Chat Completion


Environment Configuration


Troubleshooting

Traces not appearing

  1. Check environment variables - Ensure HH_API_KEY is set
  2. Pass the tracer provider - The instrumentor must receive tracer_provider=tracer.provider:
  1. Initialize before making calls - Call instrument() before creating the OpenAI client

Enrich Your Traces

Add user IDs and custom metadata to traces

Custom Spans

Create spans for business logic around API calls

Distributed Tracing

Trace calls across service boundaries

Resources