Skip to content

Phoenix

Install

In a separate non-project folder, install and run phoenix as a local instance:

uv init phoenix-local
cd phoenix-local
uv add phoenix
uv add openai
Run:
uv run phoenix serve
Phoenix would now be available at http://127.0.0.1:6006

Quick Start

Tracing

Install and register tracer in the project.

uv add arize-phoenix-otel
uv add openinference-instrumentation-openai
Example code with phoenix tracing:
import os
from phoenix.otel import register
import openai
from getpass import getpass

# Register Tracer
tracer_provider = register(
    project_name="my-llm-app",
    auto_instrument=True,
)

tracer = tracer_provider.get_tracer(__name__)

# OpenAI Example
if not (openai_api_key := os.getenv("OPENAI_API_KEY")):
    openai_api_key = getpass("🔑 Enter your OpenAI API key: ")
os.environ["OPENAI_API_KEY"] = openai_api_key

client = openai.OpenAI()
response = client.responses.create(
    model="gpt-4o",
    input=[
        {"role": "user", "content": "Why is the sky blue?"}
    ]
)
print(response.output_text)

Prompt Playground

  1. Run Phoenix local and go to http://127.0.0.1:6006/playground
  2. Add OpenAI key.
  3. Choose model, system prompt and user prompt.
  4. Run.
  5. Save prompts with versioning.

References

  1. Phoenix Getting Started