CLI Reference¶
opik¶
CLI tool for Opik.
Usage
opik [OPTIONS] COMMAND [ARGS]...
Options
- -v, --version¶
Show the version and exit.
- --api-key <api_key>¶
Opik API key. If not provided, will use OPIK_API_KEY environment variable or configuration.
configure¶
Create a configuration file for the Opik Python SDK, if a configuration file already exists, it will be overwritten. This is also available as a function in the Python SDK.
Usage
opik configure [OPTIONS] COMMAND [ARGS]...
Options
- --use_local, --use-local¶
Flag to configure the Opik Python SDK for local Opik deployments.
- -y, --yes¶
Flag to automatically answer yes whenever a user approval might be required
- --install-mcp, --no-install-mcp¶
Register the Opik MCP server with detected AI hosts (Claude Code, Cursor, VS Code). When omitted, you are prompted interactively.
status¶
Show the active Opik configuration: file path, environment, and workspace.
Usage
opik configure status [OPTIONS]
connect¶
Run or stop a local bridge daemon to Opik.
Usage
opik connect [OPTIONS] COMMAND [ARGS]...
stop¶
Stop a local connect runner started in another terminal.
Usage
opik connect stop [OPTIONS]
Options
- --project <project_name>¶
Stop the connect runner bound to this project.
- --all¶
Stop every local connect runner.
- --runner <runner_id>¶
Stop the connect runner with this id. Use when a project has more than one runner attached to it.
endpoint¶
Run or stop a local endpoint process connected to Opik.
Usage
opik endpoint [OPTIONS] COMMAND [ARGS]...
stop¶
Stop a local endpoint runner started in another terminal.
Usage
opik endpoint stop [OPTIONS]
Options
- --project <project_name>¶
Stop the endpoint runner bound to this project.
- --all¶
Stop every local endpoint runner.
- --runner <runner_id>¶
Stop the endpoint runner with this id. Use when a project has more than one runner attached to it.
export¶
Export data from an Opik project.
In Opik v2 every dataset, prompt, and experiment belongs to a project, so
exports are always scoped to a single project named on the command line.
Exported data is written under PATH/WORKSPACE/projects/PROJECT/.
# Export only datasets and prompts opik export my-workspace my-project all –include datasets,prompts
# Export a specific dataset opik export my-workspace my-project dataset “my-dataset”
# Export the project’s traces with an OQL filter opik export my-workspace my-project traces –filter “status:completed”
# Export an experiment with dataset filter (by name or ID) opik export my-workspace my-project experiment “my-experiment” –dataset “my-dataset” opik export my-workspace my-project experiment “01234567-89ab-cdef-0123-456789abcdef” –dataset “my-dataset”
# Export in CSV format to a specific directory opik export my-workspace my-project prompt “my-template” –format csv –path ./custom-exports
Usage
opik export [OPTIONS] WORKSPACE PROJECT ITEM [ARGS]...
Options
- --api-key <api_key>¶
Opik API key. If not provided, will use OPIK_API_KEY environment variable or configuration.
Arguments
- WORKSPACE¶
Required argument
- PROJECT¶
Required argument
all¶
Export all datasets, prompts, experiments, and traces from the project.
Downloads everything in the project in dependency order: datasets and prompts first, then traces, then experiments. Items already downloaded are skipped unless –force is set.
# Export only datasets and prompts opik export my-workspace my-project all –include datasets,prompts
# Re-download everything to a custom path opik export my-workspace my-project all –force –path ./backup
Usage
opik export WORKSPACE PROJECT all [OPTIONS]
Options
- --filter <filter>¶
OQL filter string applied to project and experiment traces (e.g. ‘created_at >= “2024-01-01T00:00:00Z”’).
- -p, --path <path>¶
Directory to save exported data. Defaults to opik_exports.
- --format <format>¶
Format for exporting data. Defaults to json.
- Options:
json | csv
- --force¶
Re-download items even if they already exist locally.
- --debug¶
Enable debug output to show detailed information about the export process.
- --include <include>¶
Comma-separated list of data types to export. Valid values: datasets, experiments, prompts, traces. Defaults to all: datasets,prompts,traces,experiments.
- --max-results <max_results>¶
Maximum number of traces/items to export per entity.
- --no-attachments¶
Skip downloading attachment files.
- --page-size <page_size>¶
Number of traces to fetch per API request when exporting projects. Larger values reduce round-trips but increase memory usage.
- Default:
500
dataset¶
Export a dataset by exact name to projects/<project>/datasets.
Usage
opik export WORKSPACE PROJECT dataset [OPTIONS] NAME
Options
- --max-results <max_results>¶
Maximum number of datasets to export. Limits the total number of datasets downloaded.
- -p, --path <path>¶
Directory to save exported data. Defaults to opik_exports.
- --force¶
Re-download items even if they already exist locally.
- --debug¶
Enable debug output to show detailed information about the export process.
- --format <format>¶
Format for exporting data. Defaults to json.
- Options:
json | csv
Arguments
- NAME¶
Required argument
experiment¶
Export an experiment by exact name to projects/<project>/experiments.
The command will first try to find the experiment by ID. If not found, it will try by name.
Usage
opik export WORKSPACE PROJECT experiment [OPTIONS] NAME_OR_ID
Options
- --filter <filter>¶
OQL filter string applied to traces (e.g. ‘created_at >= “2024-01-01T00:00:00Z”’).
- --dataset <dataset>¶
Filter experiments by dataset name. Only experiments using this dataset will be exported.
- --max-traces <max_traces>¶
Maximum number of traces to export per experiment. Limits the total number of traces downloaded.
- -p, --path <path>¶
Directory to save exported data. Defaults to opik_exports.
- --force¶
Re-download items even if they already exist locally.
- --debug¶
Enable debug output to show detailed information about the export process.
- --format <format>¶
Format for exporting data. Defaults to json.
- Options:
json | csv
Arguments
- NAME_OR_ID¶
Required argument
prompt¶
Export a prompt by exact name to projects/<project>/prompts.
Usage
opik export WORKSPACE PROJECT prompt [OPTIONS] NAME
Options
- --max-results <max_results>¶
Maximum number of prompts to export. Limits the total number of prompts downloaded.
- -p, --path <path>¶
Directory to save exported data. Defaults to opik_exports.
- --force¶
Re-download items even if they already exist locally.
- --debug¶
Enable debug output to show detailed information about the export process.
- --format <format>¶
Format for exporting data. Defaults to json.
- Options:
json | csv
Arguments
- NAME¶
Required argument
traces¶
Export the project’s traces to projects/<project>/.
Usage
opik export WORKSPACE PROJECT traces [OPTIONS]
Options
- --filter <filter>¶
Filter string to narrow down traces using Opik Query Language (OQL).
- --max-results <max_results>¶
Maximum number of traces to export. Limits the total number of traces downloaded.
- -p, --path <path>¶
Directory to save exported data. Defaults to opik_exports.
- --force¶
Re-download items even if they already exist locally.
- --debug¶
Enable debug output to show detailed information about the export process.
- --format <format>¶
Format for exporting data. Defaults to json.
- Options:
json | csv
- --no-attachments¶
Skip downloading attachment files.
- --page-size <page_size>¶
Number of traces to fetch per API request. Larger values reduce round-trips but increase memory usage.
- Default:
500
harbor¶
Run Harbor benchmarks with Opik tracking enabled.
Usage
opik harbor [OPTIONS]
healthcheck¶
Performs a health check of the application, including validation of configuration, verification of library installations, and checking the availability of the backend workspace. Prints all relevant information to assist in debugging and diagnostics.
When –smoke-test is used, runs a smoke test to verify Opik integration is working correctly. The smoke test performs a basic sanity test by: - Creating a trace with random data - Adding a tracked LLM completion span - Attaching a dynamically generated test image - Verifying data is sent to Opik
Examples:
Run standard healthcheck:
opik healthcheck
Run healthcheck with smoke test:
opik healthcheck –smoke-test my-workspace
Run smoke test with custom project name:
opik healthcheck –smoke-test my-workspace –project-name my-test-project
Run healthcheck with specific workspace permissions check:
opik healthcheck –check-permissions my-workspace
Usage
opik healthcheck [OPTIONS]
Options
- --show-installed-packages¶
Print the list of installed packages to the console.
- --smoke-test <WORKSPACE>¶
Run a smoke test to verify Opik integration is working correctly. Requires WORKSPACE value.
- --project-name <project_name>¶
Project name for the smoke test (only used when –smoke-test is provided). Defaults to ‘smoke-test-project’.
- --check-permissions <WORKSPACE>¶
Allows to check user permissions in specific workspace using API key either provided using –api-key or from config file. Requires WORKSPACE value.
import¶
Import data into an Opik project.
In Opik v2 every dataset, prompt, and experiment belongs to a project, so
imports are always scoped to a single project named on the command line.
Data is read from the same layout opik export writes — folders are keyed
by project id on disk and the project name is matched against each project’s
project.json, so the same --path round-trips between export and import.
A migration_manifest.db file is automatically maintained under the project directory. If an import is interrupted, re-running the same command resumes from where it left off without creating duplicates. Use –force to discard the manifest and restart.
# Preview what would be imported opik import my-workspace my-project all –dry-run
# Import into a different workspace opik import source-workspace my-project all –to-workspace dest-workspace
# Import into a different workspace and a different project opik import source-workspace my-project all –to-workspace dest-workspace –to-project new-project
# Import the project’s traces opik import my-workspace my-project traces
# Import a specific dataset opik import my-workspace my-project dataset “my-dataset”
# Import from a custom path opik import my-workspace my-project all –path ./custom-exports/
# Resume an interrupted import (automatic — just re-run the same command) opik import my-workspace my-project all
# Discard progress and restart from scratch opik import my-workspace my-project all –force
Usage
opik import [OPTIONS] WORKSPACE PROJECT ITEM [ARGS]...
Options
- --api-key <api_key>¶
Opik API key. If not provided, will use OPIK_API_KEY environment variable or configuration.
Arguments
- WORKSPACE¶
Required argument
- PROJECT¶
Required argument
all¶
Import all datasets, prompts, traces, and experiments into the project.
Reads from the directory structure produced by ‘opik export WORKSPACE PROJECT all’. A single migration manifest tracks progress across all data types, so an interrupted import can be resumed by re-running the same command.
Import order: datasets → prompts → traces → experiments. Experiments depend on datasets, prompts, and traces being present, so earlier phases are always run first when included.
# Preview what would be imported opik import my-workspace my-project all –dry-run
# Import only datasets and prompts opik import my-workspace my-project all –include datasets,prompts
# Import into a different workspace opik import src-workspace my-project all –to-workspace dest-workspace
# Import into a different workspace and project opik import src-workspace my-project all –to-workspace dest-workspace –to-project new-project
# Restart from scratch, discarding previous progress opik import my-workspace my-project all –force
# Import from a custom path opik import my-workspace my-project all –path ./backup
Usage
opik import WORKSPACE PROJECT all [OPTIONS]
Options
- -p, --path <path>¶
Directory containing exported data. Defaults to opik_exports.
- --dry-run¶
Show what would be imported without actually importing.
- --force¶
Discard the migration manifest and re-import everything from scratch.
- --debug¶
Enable debug output to show detailed information about the import process.
- --include <include>¶
Comma-separated list of data types to import. Valid values: datasets, experiments, prompts, traces. Defaults to all: datasets,prompts,traces,experiments.
- --no-attachments¶
Skip uploading attachment files.
- --to-project <to_project>¶
Create the imported data in this project instead of the source project’s name.
- --to-workspace <to_workspace>¶
Import data into this workspace instead of WORKSPACE. WORKSPACE is still used to locate the exported files on disk.
dataset¶
Import datasets from projects/PROJECT/datasets.
This command imports datasets matching the specified name from the source project’s datasets directory. The name is matched using case-insensitive substring matching.
Usage
opik import WORKSPACE PROJECT dataset [OPTIONS] NAME
Options
- -p, --path <path>¶
Directory containing exported data. Defaults to opik_exports.
- --dry-run¶
Show what would be imported without actually importing.
- --force¶
Discard the migration manifest and re-import everything from scratch.
- --debug¶
Enable debug output to show detailed information about the import process.
- --to-project <to_project>¶
Create the imported data in this project instead of the source project’s name.
- --to-workspace <to_workspace>¶
Import data into this workspace instead of WORKSPACE. WORKSPACE is still used to locate the exported files on disk.
Arguments
- NAME¶
Required argument
experiment¶
Import experiments from projects/PROJECT/experiments.
This command imports experiments matching the specified name from the source project’s experiments directory. The name is matched using case-insensitive substring matching.
If a previous import was interrupted, re-running the same command automatically resumes from where it left off. Use –force to start over from scratch.
Usage
opik import WORKSPACE PROJECT experiment [OPTIONS] NAME
Options
- -p, --path <path>¶
Directory containing exported data. Defaults to opik_exports.
- --dry-run¶
Show what would be imported without actually importing.
- --force¶
Discard the migration manifest and re-import everything from scratch.
- --debug¶
Enable debug output to show detailed information about the import process.
- --to-project <to_project>¶
Create the imported data in this project instead of the source project’s name.
- --to-workspace <to_workspace>¶
Import data into this workspace instead of WORKSPACE. WORKSPACE is still used to locate the exported files on disk.
Arguments
- NAME¶
Required argument
prompt¶
Import prompts from projects/PROJECT/prompts.
This command imports prompts matching the specified name from the source project’s prompts directory. The name is matched using case-insensitive substring matching.
Usage
opik import WORKSPACE PROJECT prompt [OPTIONS] NAME
Options
- -p, --path <path>¶
Directory containing exported data. Defaults to opik_exports.
- --dry-run¶
Show what would be imported without actually importing.
- --force¶
Discard the migration manifest and re-import everything from scratch.
- --debug¶
Enable debug output to show detailed information about the import process.
- --to-project <to_project>¶
Create the imported data in this project instead of the source project’s name.
- --to-workspace <to_workspace>¶
Import data into this workspace instead of WORKSPACE. WORKSPACE is still used to locate the exported files on disk.
Arguments
- NAME¶
Required argument
traces¶
Import the project’s traces from projects/PROJECT/.
Reads the trace files exported under the source project’s folder and recreates the traces and their spans in the destination project.
If a previous import was interrupted, re-running the same command automatically resumes from where it left off. Use –force to start over from scratch.
Usage
opik import WORKSPACE PROJECT traces [OPTIONS]
Options
- -p, --path <path>¶
Directory containing exported data. Defaults to opik_exports.
- --dry-run¶
Show what would be imported without actually importing.
- --force¶
Discard the migration manifest and re-import everything from scratch.
- --debug¶
Enable debug output to show detailed information about the import process.
- --no-attachments¶
Skip uploading attachment files.
- --to-project <to_project>¶
Create the imported data in this project instead of the source project’s name.
- --to-workspace <to_workspace>¶
Import data into this workspace instead of WORKSPACE. WORKSPACE is still used to locate the exported files on disk.
mcp¶
Manage the Opik MCP server integration.
Usage
opik mcp [OPTIONS] COMMAND [ARGS]...
configure¶
Register the Opik MCP server with your AI assistant(s).
Reuses your existing Opik configuration (~/.opik.config), so run opik configure first if you have not configured Opik yet.
By default this uses the Comet-hosted MCP server when your deployment offers one, falling back to a local server otherwise. Pass –local-server to force the local server.
Usage
opik mcp configure [OPTIONS]
Options
- --local-server¶
Install the local MCP server (run via uvx) instead of the Comet-hosted one, even when your deployment offers a hosted server.
status¶
Show which AI assistants the Opik MCP server is configured for.
Each AI assistant keeps its own MCP config, written at install time and not kept in sync with ~/.opik.config afterwards. This lists every assistant that has the Opik MCP server set up, what it points at, and whether that still matches your Opik configuration.
Usage
opik mcp status [OPTIONS]
migrate¶
Migrate Opik entities between projects (within a single workspace).
# Migrate a prompt (full version history) opik migrate prompt “MyPrompt” –to-project=B
# Preview the migration without touching the backend opik migrate dataset “MyDataset” –to-project=B –dry-run
# Override the configured workspace per-invocation opik migrate –workspace=production dataset “MyDataset” –to-project=B
Usage
opik migrate [OPTIONS] COMMAND [ARGS]...
Options
- --workspace <workspace>¶
Workspace name. Falls back to OPIK_WORKSPACE env var, then ~/.opik.config, then ‘default’.
- --api-key <api_key>¶
Opik API key. If not provided, will use OPIK_API_KEY environment variable or configuration.
dataset¶
Migrate a dataset (and its full version history) into –to-project.
The source keeps its original name for the entire copy, so an interrupted run leaves the source untouched and only a discardable “<name>__migrating” dataset behind. Re-running with the original name is therefore safe and idempotent: a stale temp from a prior failed run is discarded and the copy restarts from scratch (OPIK-7162).
Pass --exclude-experiments to stop before the cascade (step 3): the
dataset and its versions migrate, but experiments and optimizations are
skipped entirely (no discovery pass runs).
If a migration is interrupted (crash, network drop, OOM), re-running the same command from the same machine resumes from the last completed experiment instead of restarting: already-completed experiments are skipped, and an experiment that was interrupted mid-flight has its partial destination data cleaned up before it is re-migrated (so no duplicates are left behind). Progress is checkpointed locally per experiment, keyed by workspace + destination project + dataset name, in a file next to the audit log; it is removed once the migration completes successfully.
Dataset names are workspace-unique on the BE
(UNIQUE (workspace_id, name)); --from-project is an
optional source-scope hint that yields a smaller BE result set and
a clearer not-found error message.
Usage
opik migrate dataset [OPTIONS] NAME
Options
- --to-project <to_project>¶
Required Destination project name (required).
- --from-project <from_project>¶
Optional source project name. Omit to look up workspace-scoped datasets (V1 entities, or anything left at workspace scope after auto-migration). When provided, scopes the lookup to the named project for a smaller BE result set and a clearer not-found message.
- --exclude-experiments¶
Migrate the dataset and its full version history but skip all experiment (and optimization) migration. Opt-out and off by default; a plain run migrates experiments as before.
- --dry-run¶
Preview the migration without applying any changes.
- --audit-log <audit_log>¶
Path to write the audit-log JSON file (default: ./opik-migrate-<timestamp>.json).
Arguments
- NAME¶
Required argument
prompt¶
Migrate a prompt (and its full version history) into –to-project.
Prompt names are workspace-unique on the BE
(UNIQUE (workspace_id, name)); --from-project is an optional
source-scope hint that yields a smaller BE result set and a clearer
not-found error message.
Usage
opik migrate prompt [OPTIONS] NAME
Options
- --to-project <to_project>¶
Required Destination project name (required).
- --from-project <from_project>¶
Optional source project name. Omit to look up workspace-scoped prompts (V1 entities, or anything left at workspace scope after auto-migration). When provided, scopes the lookup to the named project for a smaller BE result set and a clearer not-found message.
- --dry-run¶
Preview the migration without applying any changes.
- --audit-log <audit_log>¶
Path to write the audit-log JSON file (default: ./opik-migrate-<timestamp>.json).
Arguments
- NAME¶
Required argument
proxy¶
Start the Opik server.
Usage
opik proxy [OPTIONS]
Options
- --ollama¶
Run as a proxy server for Ollama
- --ollama-host <ollama_host>¶
Ollama server URL when using –ollama-proxy
- Default:
'http://localhost:11434'
- --lm-studio¶
Run as a proxy server for LM Studio
- --lm-studio-host <lm_studio_host>¶
LM Studio server URL when using –lm-studio-proxy
- Default:
'http://localhost:1234'
- --host <host>¶
Host to bind to
- Default:
'localhost'
- --port <port>¶
Port to bind to
- Default:
7860
usage-report¶
Extract Opik usage data for one or more workspaces.
This command extracts project-level metrics from Opik for specified workspace(s): - Loops through all projects in each workspace - Gets trace count, cost, and token count - Gets experiment and dataset counts (workspace-level) - Aggregates data by the specified time unit (month, week, day, or hour) - Saves data to a JSON file - Generates a PDF report with charts and statistics
- WORKSPACES: Zero or more workspace names to extract data from.
If no workspaces are provided, all workspaces will be processed.
Examples:
Extract data for a single workspace with auto-detected date range:
opik usage-report my-workspace
Extract data for multiple workspaces:
opik usage-report workspace1 workspace2 workspace3
Extract data for all workspaces (no workspace specified):
opik usage-report
Extract data aggregated by week:
opik usage-report my-workspace –unit week
Extract data for specific date range, aggregated by day:
opik usage-report my-workspace –start-date 2024-01-01 –end-date 2024-12-31 –unit day
Extract data and automatically open the PDF report:
opik usage-report my-workspace –open
Generate PDF from existing JSON file (skip data extraction):
opik usage-report my-workspace –from-json
Usage
opik usage-report [OPTIONS] [WORKSPACES]...
Options
- --start-date <start_date>¶
Start date (YYYY-MM-DD). Defaults to None (auto-detect from data).
- --end-date <end_date>¶
End date (YYYY-MM-DD). Defaults to None (auto-detect from data).
- --unit <unit>¶
Time unit for aggregation (month, week, day, or hour). Defaults to ‘month’.
- Options:
month | week | day | hour
- -o, --output <output>¶
Output JSON file path. Defaults to opik_usage_report.json.
- --open¶
Automatically open the generated PDF report in the default viewer.
- --from-json¶
Load data from existing JSON files instead of extracting from API. JSON files should match the output pattern (e.g., opik_usage_report.json or opik_usage_report_{workspace}.json).
Arguments
- WORKSPACES¶
Optional argument(s)