Skip to main content
Note*: This instrumentation also works with Azure OpenAI

Install

Setup

Add your OpenAI API key as an environment variable:
Connect your application to Phoenix with the register function:

Run OpenAI

Observe

Now that you have tracing setup, all invocations of OpenAI (chat completions, completions, the Responses API, embeddings, images, and decisions) will be streamed to your running Phoenix for observability and evaluation.

Decisions API

The OpenAI Decisions API (client.decisions.create) asks a decision model a fixed set of typed questions about text or images. It returns one typed, probabilistic answer per question instead of generated text, which makes it a good fit for routing, classification, and scoring inside your application. Requires openai >= 3.26.0 and openinference-instrumentation-openai >= 0.1.64. Calls are traced with the setup above, with no extra configuration:
Each call shows up in Phoenix as a DECISION span rather than an LLM span, containing:
  • input.value: the request body (model, input, questions) as JSON
  • output.value: the response body (answers, model, usage) as JSON
  • decision.system: openai
  • decision.provider: inferred from the client’s host, so openai, or azure for Azure OpenAI
  • decision.request.model_name, decision.response.model_name, and decision.model_name
  • decision.token_count.input and decision.token_count.output, from the response’s usage
Phoenix names the decision model in the span’s input card. The model and its usage are recorded under decision.* rather than llm.*, so decision-model calls stay out of Phoenix’s LLM token and cost reporting. The questions and answers live only in input.value and output.value, so TraceConfig(hide_inputs=True) and hide_outputs=True redact them completely. hide_input_images applies to inline images in the input.

Resources