Note: This instrumentation also works with Azure OpenAI

Phoenix provides auto-instrumentation for the OpenAI Python Library.

To view OpenAI spans in Phoenix, you will first have to start a Phoenix server. You can do this by running the following:

import phoenix as px
session = px.launch_app()

Once you have started a Phoenix server, you can instrument the OpenAI Python library using the OpenAIInstrumentor.

from phoenix.trace.openai import OpenAIInstrumentor


All subsequent calls to ChatCompletion and will now export spans to the Phoenix server. These spans will show up in the UI as they are collected.

# View in the browser

Last updated