Phoenix CLI (@arizeai/phoenix-cli) is a command-line interface tool for retrieving trace data from your Phoenix projects. It allows you to use Phoenix’s tracing and debugging features directly in your terminal and development workflows.
You can use Phoenix CLI for the following use cases:
- Immediate debugging: Fetch the most recent trace of a failed or unexpected run with a single command.
- Bulk export for analysis: Export large numbers of traces to JSON files for offline analysis, building evaluation datasets, or regression tests.
- Terminal-based workflows: Integrate trace data into your existing tools; for example, piping output to Unix utilities like
jq, or feeding traces into an AI coding assistant for automated analysis. - AI coding assistant integration: Use with Claude Code, Cursor, Windsurf, or other AI-powered development tools to analyze and debug your LLM application traces.
Installation#
Or run directly without installation:
Setup#
1. Set your Phoenix endpoint#
For a remote deployment:
2. Set your project name#
The CLI will automatically fetch traces from PHOENIX_PROJECT. Replace your-project-name with the name of your Phoenix project.
3. Set your API key (if required)#
If your Phoenix instance has authentication enabled, you’ll need to set the PHOENIX_API_KEY environment variable or use the --api-key flag.
Use with AI Coding Assistants#
The Phoenix CLI pairs well with AI coding assistants like Claude Code, Cursor, Windsurf, and others. There are two ways to wire it up.
Connect the assistant to Phoenix directly (recommended)#
Rather than pasting CLI output into a chat, connect the assistant to Phoenix once and let it query on its own:
- MCP — register the Phoenix MCP server with your agent using
px setup mcp --agent cursor(swap inclaude,codex, and so on). The agent then reaches your traces, projects, and docs through the remote MCP server built into Phoenix, without you copying anything by hand. - Skills —
px setup skillsinstalls Phoenix skills so agents that support them know how to call the CLI. See Coding Agents.
Ask the assistant to run the CLI#
An assistant with terminal access can also run px directly. Ask Claude Code something like:
It discovers the available commands through px --help and fetches the traces itself. For an assistant without terminal access, run a command such as px trace list --limit 5 --format json yourself and paste the output into the chat.
Find Project and Trace IDs#
In most cases, you won’t need to find IDs manually (the CLI uses your environment’s project name and latest traces by default). However, if you want to fetch a specific item by ID, you can find the IDs in the Phoenix UI:
- Project Name/ID: Each project has a unique name and ID. You can find it in the project selector dropdown or in the project’s URL.
- Trace ID: Every trace has an ID. In the traces view, click on a specific trace to see its Trace ID (copyable from the trace details panel). You can use
px trace get <trace-id>to retrieve that exact trace.
Usage#
After installation and setup, you can use the px command to retrieve traces. The general usage is:
Phoenix CLI provides the following commands:
| Command | Fetches | Output location |
|---|---|---|
project list | List of all projects | stdout |
trace get <id> | A specific trace by ID | stdout (or to a file with --file) |
trace list [directory] | Recent traces from the project | Saves each trace as a JSON file in the given directory, or prints to stdout if no directory is provided |
session list | List sessions for a project | stdout |
session get <id> | A specific session with its traces | stdout (or to a file with --file) |
Traces are fetched chronologically with most recent first.
Options#
The commands support additional flags to filter and format the output:
| Option / Flag | Applies to | Description | Default |
|---|---|---|---|
-n, --limit <int> | trace list | Maximum number of traces to fetch | 10 |
--last-n-minutes <int> | trace list | Only fetch traces from the last N minutes | No filter |
--since <timestamp> | trace list | Only fetch traces since a specific time (ISO 8601 format) | No filter |
--project <name> | trace get, trace list | Override the configured project | From env |
--format <type> | All commands | Output format: pretty, json, or raw | pretty |
--file <path> | trace get | Save the fetched trace to a file instead of printing | stdout |
--max-concurrent <int> | trace list | Maximum concurrent fetch requests | 10 |
--no-progress | All commands | Disable progress bar output (useful for scripts and AI assistants) | Progress on |
--include-annotations | trace get, trace list | Include span annotations in trace export | Off |
Output formats#
The --format option controls how the fetched data is displayed:
-
pretty(default): A human-readable tree view showing span hierarchy, status, and timing. Great for quick debugging: -
json: Well-formatted JSON output with indentation. Use this if you want to examine the data structure: -
raw: Compact JSON with no extra whitespace. Ideal for piping tojqor other tools:
Fetch a Single Trace#
You can fetch a single trace with its ID. The command will output to the terminal by default:
You can optionally save the trace to a file using the --file option:
To include span annotations in the trace export:
To fetch a trace from a different project than the one configured:
Fetch Multiple Traces#
For bulk fetches of traces, we recommend specifying a target directory path. Each fetched trace will be saved as a separate JSON file in that folder, making it easy to browse or process them later.
You can specify a destination directory for bulk exports. For example, the following command will save the 10 most recent traces as JSON files in the my-traces-data directory:
Include span annotations in the export:
If you omit the directory, the tool will output the results to your terminal:
When saving to a directory, files will be named by trace ID (e.g., 3b0b15fe-1e3a-4aef-afa8-48df15879cfe.json).
Filter by time#
Fetch traces from a specific time range:
Export to Files#
You can fetch traces and export them for offline analysis or building datasets:
This command retrieves traces that occurred since January 1, 2026, saving each as a JSON file under ./exported-traces. This is useful for:
- Building regression test datasets
- Offline analysis and debugging
- Creating evaluation datasets for experiments
Sessions#
Sessions group multiple traces into a single multi-turn conversation. Use the session list and session get commands to explore them.
List Sessions#
View a Session#
To drill into a specific turn’s input/output, use px trace get <trace-id> with the trace ID from the session output.
Trace Output Structure#
When using json or raw format, traces are output with the following structure:
OpenInference Semantic Attributes#
Each span includes OpenInference semantic attributes in the attributes field:
- LLM spans:
llm.model_name,llm.token_count.prompt,llm.token_count.completion,llm.invocation_parameters - Input/Output:
input.value,output.value,input.mime_type,output.mime_type - Tool calls:
tool.name,tool.description,tool.parameters - Retrieval:
retrieval.documents - Errors:
exception.type,exception.message,exception.stacktrace
AI Coding Assistant Examples#
Debug a Failed Agent Run#
Then ask your AI assistant:
Analyze Agent Performance#
Ask your AI assistant:
Review Token Usage#
Pipeline Examples#
The CLI is designed to work seamlessly in shell pipelines:
Troubleshooting#
”Phoenix endpoint not configured”#
Set the PHOENIX_ENDPOINT environment variable:
Or use the --endpoint flag:
“Project not configured”#
Set the PHOENIX_PROJECT environment variable:
Or use the --project flag:
“Failed to resolve project”#
Make sure your project name or ID is correct. List available projects:

