Skip to main content
Glama

@arizeai/phoenix-mcp

Official
by Arize-ai
openai-tracing.md1.82 kB
# OpenAI Tracing Phoenix provides auto-instrumentation for the [OpenAI Python Library](https://github.com/openai/openai-python). {% hint style="info" %} **Note**_:_ This instrumentation also works with Azure OpenAI {% endhint %} ## Launch Phoenix We have several code samples below on different ways to integrate with OpenAI, based on how you want to use Phoenix. {% include "../../../../phoenix-integrations/.gitbook/includes/sign-up-for-phoenix-sign-up....md" %} ## Install ```bash pip install openinference-instrumentation-openai openai ``` ## Setup Add your OpenAI API key as an environment variable: ```bash export OPENAI_API_KEY=[your_key_here] ``` Use the register function to connect your application to Phoenix: ```python from phoenix.otel import register # configure the Phoenix tracer tracer_provider = register( project_name="my-llm-app", # Default is 'default' auto_instrument=True # Auto-instrument your app based on installed dependencies ) ``` ## Run OpenAI ```python import openai client = openai.OpenAI() response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": "Write a haiku."}], ) print(response.choices[0].message.content) ``` ## Observe Now that you have tracing setup, all invocations of OpenAI (completions, chat completions, embeddings) will be streamed to your running Phoenix for observability and evaluation. ## Resources * [Example notebook](https://github.com/Arize-ai/phoenix/blob/main/tutorials/tracing/openai_tracing_tutorial.ipynb) * [OpenInference package](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-openai) * [Working examples](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-openai/examples)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arize-ai/phoenix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server