Skip to main content
Glama

@arizeai/phoenix-mcp

Official
by Arize-ai
openai-agents-sdk-tracing.md3.57 kB
--- description: Use Phoenix and OpenAI Agents SDK for powerful multi-agent tracing --- # OpenAI Agents SDK Tracing ## 1. Launch Phoenix We have several code samples below on different ways to integrate with OpenAI, based on how you want to use Phoenix. {% tabs %} {% tab title="Phoenix Cloud" %} **Sign up for Phoenix:** Sign up for an Arize Phoenix account at [https://app.phoenix.arize.com/login](https://app.phoenix.arize.com/login) **Install packages:** ```bash pip install arize-phoenix-otel ``` **Set your Phoenix endpoint and API Key:** ```python import os # Add Phoenix API Key for tracing PHOENIX_API_KEY = "ADD YOUR API KEY" os.environ["PHOENIX_CLIENT_HEADERS"] = f"api_key={PHOENIX_API_KEY}" os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com" ``` Your **Phoenix API key** can be found on the Keys section of your [dashboard](https://app.phoenix.arize.com). {% endtab %} {% tab title="Command Line" %} **Launch your local Phoenix instance:** ```bash pip install arize-phoenix phoenix serve ``` For details on customizing a local terminal deployment, see [Terminal Setup](https://arize.com/docs/phoenix/setup/environments#terminal). **Install packages:** ```bash pip install arize-phoenix-otel ``` **Set your Phoenix endpoint:** ```python import os os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "http://localhost:6006" ``` See Terminal for more details {% endtab %} {% tab title="Docker" %} **Pull latest Phoenix image from** [**Docker Hub**](https://hub.docker.com/r/arizephoenix/phoenix)**:** ```bash docker pull arizephoenix/phoenix:latest ``` **Run your containerized instance:** ```bash docker run -p 6006:6006 arizephoenix/phoenix:latest ``` This will expose the Phoenix on `localhost:6006` **Install packages:** ```bash pip install arize-phoenix-otel ``` **Set your Phoenix endpoint:** ```python import os os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "http://localhost:6006" ``` For more info on using Phoenix with Docker, see [Docker](https://arize.com/docs/phoenix/self-hosting/deployment-options/docker). {% endtab %} {% tab title="Notebook" %} **Install packages:** ```bash pip install arize-phoenix ``` **Launch Phoenix:** ```python import phoenix as px px.launch_app() ``` {% hint style="info" %} By default, notebook instances do not have persistent storage, so your traces will disappear after the notebook is closed. See [self-hosting](https://arize.com/docs/phoenix/self-hosting) or use one of the other deployment options to retain traces. {% endhint %} {% endtab %} {% endtabs %} ## 2. Install ```bash pip install openinference-instrumentation-openai-agents openai-agents ``` ## 3. Set up Tracing 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="agents", # Default is 'default' auto_instrument=True # Auto-instrument your app based on installed dependencies ) ``` Run your `agents`code. ```python from agents import Agent, Runner agent = Agent(name="Assistant", instructions="You are a helpful assistant") result = Runner.run_sync(agent, "Write a haiku about recursion in programming.") print(result.final_output) ``` View your traces in Phoenix. ## Resources * [Example notebook](https://colab.research.google.com/github/Arize-ai/phoenix/blob/c02f0e7d807129952afa5da430299aec32fafcc9/tutorials/evals/openai_agents_cookbook.ipynb#L4)

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