Import/Export by command line
Import/Export by command line
Import/Export by command line
The export/import command-line functions enable you to:
opik export WORKSPACE TYPE NAMEExports specific data types from the specified workspace to local files.
Arguments:
WORKSPACE: The workspace name to export fromTYPE: The type of data to export (all, dataset, project, experiment, or prompt)NAME: Exact name of the item to export (not used with all)Options:
--path, -p: Directory to save exported data (default: opik_exports)--max-results: Maximum number of items to export per data type (default: 1000)--filter: OQL filter string applied to traces — works with project, experiment, and all--force: Re-download items even if they already exist locally--format: Format for exporting data (json or csv, default: json)--debug: Enable debug output to show detailed information about the export process--no-attachments: Skip downloading attachment files.--page-size INTEGER: Number of traces to fetch per API request when exporting projects (1–1000, default: 500). Applies to project and all. Increase for fewer round-trips; decrease if you hit persistent rate-limit errors.all-specific options:
--include: Comma-separated list of data types to include (datasets, prompts, projects, experiments). Defaults to all four.experiment-specific options:
--dataset NAME: Filter experiments by dataset name (only experiments using this dataset will be exported)--max-traces INTEGER: Maximum number of traces to export (limits total traces downloaded)Examples:
Use all when you want to export every data type in one shot — useful for full workspace backups or bulk migrations:
Use dataset, project, experiment, or prompt when you need to export a single named item:
Use --filter to narrow exports to a time window or any OQL predicate — avoids downloading data you don’t need:
Use experiment-specific options to scope large experiment exports:
Use --format csv when the target is a spreadsheet or analysis tool rather than a re-import:
Use --no-attachments to skip downloading attachment files (faster exports when you only need trace/span data):
Miscellaneous options:
opik import WORKSPACE TYPE NAMEImports specific data types from local files to the specified workspace.
Arguments:
WORKSPACE: The workspace name to import toTYPE: The type of data to import (dataset, project, experiment, or prompt)NAME: Name pattern to match items (case-insensitive substring matching)Options:
--path, -p: Directory containing exported data (default: opik_exports)--dry-run: Show what would be imported without actually importing--force: Discard the migration manifest and re-import everything from scratch--no-attachments: Skip uploading attachment files.--debug: Enable debug output to show detailed information about the import processNote: Experiment imports automatically recreate experiments where possible. No additional flags are needed.
Every import automatically maintains a migration_manifest.db SQLite database
in the --path directory. It tracks which files have been imported and the ID
mappings needed to link experiments back to their traces.
If an import is interrupted (e.g. network error, Ctrl-C), simply re-run the same command — it will resume from where it left off without creating duplicates:
When a previously completed import is re-run:
Use --force to discard the manifest and start fresh.
Examples:
Basic imports — reads from the default opik_exports directory created by opik export:
Use a name pattern when you want to import multiple items whose names share a substring:
Use --path when your exported data is not in the default opik_exports directory:
Use --dry-run to preview what would be imported before committing — helpful to verify names and counts:
Resuming and forcing — the manifest in --path handles resumption automatically; use --force only to start over:
Use --no-attachments to skip uploading attachment files (faster imports when you only need trace/span data):
Use --debug to see per-file status and API call details:
The exported data is stored in JSON files with the following structure:
Each trace file contains:
Each evaluation rule file contains:
Each experiment file contains:
Each prompt file contains:
When using --format csv, data is exported as CSV files with flattened data structure. This format is ideal for:
CSV File Structure:
CSV Format Benefits:
Example CSV Structure:
Migration is a two-step process because the source and destination typically
have different API keys. Export with your source credentials, then import with
your destination credentials. The migration_manifest.db created during
import travels with the exported data and makes the import safe to interrupt
and resume.
To migrate all data types at once:
Import was interrupted and re-running creates duplicates
migration_manifest.db in your --path directory--path as the original runmigration_manifest.db and use --force to start fresh (this will re-import everything)“Import already completed. Use —force to re-import.”
--forceExperiment items are missing after import
--debug to see how many trace IDs were matched“No traces found”
“Project directory not found”
“Opik SDK not available”
opik healthcheck“Dataset/Project/Experiment/Prompt not found”
--debug for more detailed error information“No datasets/projects found”
“Dataset not found”
--debug to see detailed search informationExport is slow or keeps hitting rate limits
Retry-After headers where present--page-size (e.g. --page-size 100) to lower the per-request payload and decrease the chance of triggering rate limitsHere’s a complete example of exporting and importing trace data:
This workflow ensures you can safely migrate all data including experiments and prompts between workspaces while maintaining data integrity and providing visibility into the process. The CSV format is particularly useful for data analysis and reporting, while the JSON format preserves the complete structure needed for experiment and prompt recreation. The new command structure provides better organization with separate commands for datasets, projects, experiments, and prompts, making it easier to manage specific data types.