phoenix/js/packages/phoenix-cli at main · Arize-ai/phoenix
GitHub
- Immediate Debugging: Fetch the most recent trace of a failed or unexpected run with a single command
- Bulk Export: Export large numbers of traces or experiment results to JSON files for offline analysis
- Dataset & Experiment Access: List datasets and retrieve full experiment data including runs, evaluations, and trace IDs
- Prompt Introspection: View and export prompt templates for analysis, optimization, or use with other tools
- Terminal Workflows: Integrate trace and experiment data into your existing tools, piping output to Unix utilities like
jq - AI Coding Assistants: Use with Claude Code, Cursor, Windsurf, or other AI-powered tools to analyze traces, experiments, and optimize prompts
@arizeai/phoenix-cli is open-source! Issues and PRs welcome.
Installation
Quick Start
Environment Variables
CLI flags take priority over environment variables.
Profiles
A profile saves the endpoint, project, API key, and headers for a Phoenix instance under a name likeprod or staging. Activate a profile and every px command picks up those settings without re-exporting environment variables. Environment variables and CLI flags still override the active profile, so existing scripts keep working.
px profile create <name>
Create a new profile.
px profile list
List all profiles. The active profile is marked in a current column (kubectl-style).
px profile show [name]
Show a profile (defaults to the active one).
px profile use <name>
Set the active profile. Reports the transition (Switched active profile: staging → prod); a no-op if the profile is already active.
px profile edit <name>
Open a profile in $PHOENIX_EDITOR if set, otherwise $EDITOR, falling back to vi. The CLI validates the JSON on save and re-opens the editor on validation failure. Edits are discarded if the editor exits non-zero.
px profile delete <name>
Delete a profile. Deleting the active profile leaves no profile active — set a new one with px profile use <name>.
Editor autocomplete via JSON Schema
@arizeai/phoenix-cli publishes a JSON Schema for the settings file. Add a $schema key to enable autocomplete and validation in editors that support JSON Schema:
Commands
px setup
Wire your app up to Phoenix. Run it from your app’s root directory. Setup establishes the connection (endpoint, project, auth) and saves it to a gitignored .env.phoenix file, then optionally hands a coding agent (Claude Code, Codex, Cursor, OpenCode) an instrumentation task and waits until a real trace arrives. After that it can point px at the new project and install Phoenix skills so the agent can query what you captured.
px project list
List all available projects.
px project get <name>
Fetch a single project by exact name. Output is a single record (not an array). On a name miss, the command exits with a failure code and writes a structured error to stderr in --format json/raw.
px trace list [directory]
Fetch recent traces from the configured project.
px trace get <trace-id>
Fetch a specific trace by ID.
px trace annotate <trace-id>
Create or update a trace annotation by OpenTelemetry trace ID. Passing --identifier upserts a specific annotation instance, so repeated calls with the same identifier overwrite rather than append — the key primitive for reversible, script-driven coding sessions.
At least one of
--label, --score, or --explanation is required.
px trace add-note <trace-id>
Add a free-text note to a trace by OpenTelemetry trace ID. Notes are a reserved annotation type: a trace can carry multiple notes, and passing --identifier upserts a specific note instead of appending.
px trace-annotations delete
Bulk-delete trace annotations for the configured project. Requires --all (delete every matching row) or both --start-time and --end-time to bound the delete to a [start_time, end_time) window — --name, --identifier, and --annotator-kind are narrowing filters and never authorize the request on their own. Deletes are disabled by default; set PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true first.
Set
PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true to enable this command.
px span list [file]
Fetch individual spans from the configured project with comprehensive filtering.
px span annotate <span-id>
Create or update a span annotation by OpenTelemetry span ID. As with px trace annotate, passing --identifier upserts a specific annotation instance so repeated calls overwrite rather than append.
At least one of
--label, --score, or --explanation is required.
px span add-note <span-id>
Notes are a reserved annotation type. Unlike other annotations, notes are open-ended and multiple notes can be attached to the same span. Passing --identifier upserts a specific note instead of appending.
px span-annotations delete
Bulk-delete span annotations for the configured project. Same authorization gate as px trace-annotations delete — requires --all or both --start-time and --end-time, with --name/--identifier/--annotator-kind as narrowing filters. Set PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true to enable it.
px trace-annotations delete.
px session list
List sessions (multi-turn conversations) for a project.
px session get <session-id>
View a session’s conversation flow, including all traces (turns) in the session.
px session annotate <session-id>
Add or update an annotation on a session. Address the session by GlobalID or by user-provided session_id.
At least one of
--label, --score, or --explanation is required.
px session add-note <session-id>
Add a free-text note to a session. Address the session by GlobalID or by user-provided session_id. A session can carry multiple notes; passing --identifier upserts a specific note instead of appending. Requires Phoenix server >= 14.17.0.
px session-annotations delete
Bulk-delete session annotations for the configured project. Same authorization gate as the trace and span equivalents — requires --all or both --start-time and --end-time. Set PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true to enable it.
px trace-annotations delete.
px dataset list
List all available datasets.
px dataset get <dataset-identifier>
Fetch examples from a dataset.
px experiment list --dataset <name-or-id>
List experiments for a dataset, optionally exporting full data to files.
px experiment get <experiment-id>
Fetch a single experiment with all run data, including inputs, outputs, evaluations, and trace IDs.
px prompt list
List all available prompts.
px prompt get <prompt_identifier>
Show a Phoenix prompt.
Supports multiple output formats including a text format optimized for piping to AI coding assistants.
The
text format outputs prompt content with XML-style role tags, ideal for piping to AI assistants:
px annotation-config list
List annotation configurations defined in your Phoenix instance.
px annotation-config get <config-identifier>
Fetch a single annotation configuration by name or ID.
px annotation-config create
Create a new annotation configuration via POST /v1/annotation_configs. Configs come in three types: CATEGORICAL (a fixed set of labels, each with an optional numeric score), CONTINUOUS (a numeric range), and FREEFORM (free text).
--value and --values are mutually exclusive. --type and --optimization-direction are case-insensitive. Invalid input — including flags that don’t apply to the chosen type — exits with INVALID_ARGUMENT.
px annotation-config update <config-identifier>
Update an annotation configuration by name or ID. Only the fields you pass are changed — the command fetches the existing config, merges your flags, and writes the result back via PUT /v1/annotation_configs/{id}. The config type is immutable; to change it, delete and recreate the config.
At least one field flag is required. Invalid input — including flags that don’t apply to the config’s type — exits with
INVALID_ARGUMENT.
px annotation-config delete <config-id>
Delete an annotation configuration by ID. Like all delete commands, this is disabled unless PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true is set, and prompts for confirmation unless --yes is passed.
px api graphql <query>
Make authenticated GraphQL queries against the Phoenix API. Output is {"data": {...}} JSON — pipe with jq '.data.<field>' to extract values. Only queries are permitted; mutations and subscriptions are rejected before hitting the server.
Discover the schema with introspection
Use introspection to explore what fields and types are available without leaving your terminal:Projects
id, name, traceCount, recordCount, tokenCountTotal, tokenCountPrompt, tokenCountCompletion, createdAt, updatedAt.
Datasets
id, name, description, exampleCount, experimentCount, evaluatorCount, createdAt, updatedAt.
Experiments
Experiments are nested under datasets in the GraphQL schema:traceId, output, error, latencyMs, startTime, endTime.
Evaluators
Instance summary
llm.model_name, llm.token_count.*, input.value, output.value, tool.name, and exception.*.
Examples
Debug failed traces
Find slowest traces
Find errored spans
Inspect LLM spans with annotations
Extract LLM models used
Count errors
List datasets and experiments
Analyze experiment results
Work with prompts
Query the GraphQL API directly
Use with AI Coding Assistants
Phoenix CLI is designed to work seamlessly with AI coding assistants like Claude Code, Cursor, and Windsurf.Claude Code
Ask Claude Code:px --help and fetch your traces for analysis.
Prompt Optimization with Claude Code
Pipe your Phoenix prompts directly to Claude Code for analysis and optimization suggestions:Cursor / Windsurf
Run the CLI in the terminal and ask the AI to interpret:Related
Retrieve Traces via CLI
User guide for fetching traces from the command line
@arizeai/phoenix-client
TypeScript client for the Phoenix API

