Skip to main content

phoenix/js/packages/phoenix-cli at main · Arize-ai/phoenix

GitHub
Phoenix CLI is a command-line interface for your Phoenix projects. Fetch traces, list datasets, export experiment results, and access prompts directly from your terminal—or pipe them into AI coding agents like Claude Code, Cursor, Codex, and Gemini CLI. You can use Phoenix CLI for:
  • 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
Don’t see a use-case covered? @arizeai/phoenix-cli is open-source! Issues and PRs welcome.

Installation

Or run directly with npx:

Quick Start

Environment Variables

VariableDescription
PHOENIX_HOSTPhoenix API endpoint (e.g., http://localhost:6006)
PHOENIX_PROJECTProject name or ID
PHOENIX_API_KEYAPI key for authentication (if required)
PHOENIX_CLIENT_HEADERSCustom headers as JSON string
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 like prod 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.
OptionDescriptionDefault
<name>Profile name (alphanumeric, hyphens, underscores)
--endpoint <url>Phoenix API endpoint
--project <name>Default project name
--api-key <key>Phoenix API key
--header <key=value>Custom HTTP header (repeatable)
--activateMake this the active profile after creationOff

px profile list

List all profiles. The active profile is marked in a current column (kubectl-style).
OptionDescriptionDefault
--format <format>Output format: pretty, json, or rawpretty

px profile show [name]

Show a profile (defaults to the active one).
OptionDescriptionDefault
[name]Profile nameactive profile
--format <format>Output format: pretty, json, or rawpretty

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>.
OptionDescriptionDefault
--yesSkip the confirmation prompt

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 project list

List all available projects.
OptionDescriptionDefault
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>Output format: pretty, json, or rawpretty
--no-progressDisable progress indicators
--limit <number>Maximum projects to fetch per page100

px trace list [directory]

Fetch recent traces from the configured project.
OptionDescriptionDefault
[directory]Save traces as JSON files to directorystdout
-n, --limit <number>Number of traces to fetch (newest first)10
--last-n-minutes <number>Only fetch traces from the last N minutes
--since <timestamp>Fetch traces since ISO timestamp
--endpoint <url>Phoenix API endpointFrom env
--project <name>Project name or IDFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress output
--max-concurrent <number>Maximum concurrent fetches10

px trace get <trace-id>

Fetch a specific trace by ID.
OptionDescriptionDefault
--file <path>Save to file instead of stdoutstdout
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--project <name>Project name or IDFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

px span list [file]

Fetch individual spans from the configured project with comprehensive filtering.
OptionDescriptionDefault
[file]Save spans as JSON to filestdout
-n, --limit <number>Maximum spans to fetch (newest first)100
--last-n-minutes <number>Only fetch spans from the last N minutes
--since <timestamp>Fetch spans since ISO timestamp
--span-kind <kinds...>Filter by span kind (LLM, CHAIN, TOOL, RETRIEVER, EMBEDDING, AGENT, RERANKER, GUARDRAIL, EVALUATOR, UNKNOWN)
--status-code <codes...>Filter by status code (OK, ERROR, UNSET)
--name <names...>Filter by span name(s)
--trace-id <ids...>Filter by trace ID(s)
--parent-id <id>Filter by parent span ID (use "null" for root spans)
--attribute <filters...>Filter by attribute key-value pairs. Format: key:value. Repeat to AND multiple filters. Values containing colons are supported (split on first : only). To match a string attribute that looks like a number or boolean, JSON-quote the value (e.g., 'user.id:"12345"'). Requires Phoenix server ≥ 14.9.0.
--include-annotationsInclude span annotations in outputOff
--endpoint <url>Phoenix API endpointFrom env
--project <name>Project name or IDFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators

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.
OptionDescriptionDefault
<span-id>OpenTelemetry span ID
--text <text>Note text to attach to the spanRequired
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators

px session list

List sessions (multi-turn conversations) for a project.
OptionDescriptionDefault
-n, --limit <number>Maximum number of sessions to return10
--order <order>Sort order: asc or descdesc
--include-annotationsInclude session annotations, excluding notes
--include-notesInclude session notes when present
--endpoint <url>Phoenix API endpointFrom env
--project <name>Project name or IDFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators

px session get <session-id>

View a session’s conversation flow, including all traces (turns) in the session.
OptionDescriptionDefault
--include-annotationsInclude session annotations, excluding notesOff
--include-notesInclude session notes when presentOff
--file <path>Save to file instead of stdoutstdout
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--project <name>Project name or IDFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

px session annotate <session-id>

Add or update an annotation on a session. Address the session by GlobalID or by user-provided session_id.
OptionDescriptionDefault
--name <name>Annotation name (what is being measured)Required
--label <label>Categorical result (e.g. pass, fail)
--score <number>Numeric score
--explanation <text>Free-text justification
--annotator-kind <kind>HUMAN, LLM, or CODEHUMAN
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators
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; each receives a unique identifier. Requires Phoenix server >= 14.17.0.
OptionDescriptionDefault
--text <text>Note text to addRequired
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators

px dataset list

List all available datasets.
OptionDescriptionDefault
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators
--limit <number>Maximum number of datasets

px dataset get <dataset-identifier>

Fetch examples from a dataset.
OptionDescriptionDefault
--split <name>Filter by split (can be used repeatedly)
--version <id>Fetch from specific dataset versionlatest
--file <path>Save to file instead of stdoutstdout
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

px experiment list --dataset <name-or-id>

List experiments for a dataset, optionally exporting full data to files.
OptionDescriptionDefault
--dataset <name-or-id>Dataset name or ID (required)
[directory]Export experiment JSON files to directorystdout
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators
--limit <number>Maximum number of experiments

px experiment get <experiment-id>

Fetch a single experiment with all run data, including inputs, outputs, evaluations, and trace IDs.
OptionDescriptionDefault
--file <path>Save to file instead of stdoutstdout
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

px prompt list

List all available prompts.
OptionDescriptionDefault
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--format <format>pretty, json, or rawpretty
--no-progressDisable progress indicators
--limit <number>Maximum number of 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.
OptionDescriptionDefault
--tag <name>Get prompt version by tag name
--version <id>Get specific prompt version by IDlatest
--format <format>pretty, json, raw, or textpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators
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.
OptionDescriptionDefault
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators
--limit <number>Maximum number of configs

px annotation-config get <config-identifier>

Fetch a single annotation configuration by name or ID.
OptionDescriptionDefault
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

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).
OptionDescriptionDefault
--type <type>CATEGORICAL, CONTINUOUS, or FREEFORM (required)
--name <name>Annotation config name (required)
--description <description>Description
--optimization-direction <dir>MINIMIZE, MAXIMIZE, or NONENONE
--value <label[=score]>Categorical label (repeatable; CATEGORICAL configs)
--values <json>Categorical values as JSON (CATEGORICAL configs)
--lower-bound <number>Lower bound (CONTINUOUS/FREEFORM configs)
--upper-bound <number>Upper bound (CONTINUOUS/FREEFORM configs)
--threshold <number>Threshold (FREEFORM configs)
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators
--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.
OptionDescriptionDefault
--name <name>New name
--description <description>New description
--optimization-direction <dir>MINIMIZE, MAXIMIZE, or NONE
--value <label[=score]>Categorical label (repeatable; CATEGORICAL configs)
--values <json>Categorical values as JSON (CATEGORICAL configs)
--lower-bound <number>Lower bound (CONTINUOUS/FREEFORM configs)
--upper-bound <number>Upper bound (CONTINUOUS/FREEFORM configs)
--threshold <number>Threshold (FREEFORM configs)
--format <format>pretty, json, or rawpretty
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators
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.
OptionDescriptionDefault
-y, --yesSkip confirmation prompt
--endpoint <url>Phoenix API endpointFrom env
--api-key <key>Phoenix API keyFrom env
--no-progressDisable progress indicators

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.
Argument/OptionDescriptionDefault
<query>GraphQL query string
--endpoint <url>Phoenix API endpoint$PHOENIX_HOST
--api-key <key>Phoenix API key$PHOENIX_API_KEY

Discover the schema with introspection

Use introspection to explore what fields and types are available without leaving your terminal:

Projects

Available fields: id, name, traceCount, recordCount, tokenCountTotal, tokenCountPrompt, tokenCountCompletion, createdAt, updatedAt.

Datasets

Available fields: id, name, description, exampleCount, experimentCount, evaluatorCount, createdAt, updatedAt.

Experiments

Experiments are nested under datasets in the GraphQL schema:
To inspect individual run outputs, errors, and trace IDs:
Available run fields: traceId, output, error, latencyMs, startTime, endTime.

Evaluators

Instance summary

┌─ Trace: abc123def456 │ │ Input: What is the weather in San Francisco? │ Output: The weather is currently sunny… │ │ Spans: │ └─ ✓ agent_run (CHAIN) - 1250ms │ ├─ ✓ llm_call (LLM) - 800ms │ └─ ✓ tool_execution (TOOL) - 400ms └─
Spans include OpenInference semantic attributes like 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:
Claude Code will discover the CLI via 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:
You can also ask Claude Code to work with your prompts interactively:

Cursor / Windsurf

Run the CLI in the terminal and ask the AI to interpret:
For prompt work:

Retrieve Traces via CLI

User guide for fetching traces from the command line

@arizeai/phoenix-client

TypeScript client for the Phoenix API

License

Apache 2.0