Opik Configure - Interactive Setup Tool
The Opik Configure is an interactive command-line tool that streamlines the process of adding Opik observability to your Node.js and TypeScript applications. It automatically detects your project setup, installs dependencies, and configures tracing for your LLM integrations.
Features
- 🔍 Smart Detection: Automatically detects your project setup (package manager, TypeScript configuration, existing integrations)
- 📦 Package Management: Supports npm, yarn, pnpm, and bun
- ⚙️ Environment Configuration: Creates or updates
.env
files with proper Opik configuration
Getting Started
Basic Usage
Run the CLI in your project directory:
The CLI will guide you through:
- Project Detection: Identifies your package manager and project structure
- Dependency Installation: Installs Opik SDK and integration packages
- Environment Setup: Configures API keys and environment variables
- Code Generation: Sets up Opik client in your root project folder
- Formatting: Optionally applies Prettier formatting
Requirements
- Node.js: Version 18 or higher
- Package Manager: npm, yarn, pnpm, or bun
- Supported Project Types:
- Node.js applications
- TypeScript projects
- Express/Fastify APIs
CLI Options
The CLI supports several command-line options for customization:
Examples
Verbose debugging mode:
Non-interactive mode with defaults:
Install in a specific directory:
Force installation (skip peer dependency checks):
Environment Configuration
The CLI automatically creates or updates your .env
file with the necessary configuration:
The CLI will prompt you to enter your API keys during setup. For Opik Cloud,
you can get your API key from the Opik
dashboard. For self-hosted instances, set
OPIK_URL_OVERRIDE
to your server address.
Troubleshooting
Permission Errors
If you encounter permission errors during installation:
Package Manager Issues
If the CLI fails to detect your package manager:
- Ensure you have a
package.json
in your project directory - Try running the CLI with debug mode:
npx opik-configure --debug
- Manually specify your package manager by selecting it from the prompts
Environment Variable Setup
If environment variables aren’t being set correctly:
- Check that
.env
file was created in your project root - Ensure your application loads environment variables (e.g., using
dotenv
) - Restart your development server after running the CLI
Integration Not Working
If traces aren’t appearing in Opik:
- Verify your
OPIK_API_KEY
is correct - Check that
OPIK_URL_OVERRIDE
points to the right endpoint - Ensure you’re calling
flush()
before your application exits:
Debug Mode
Enable verbose logging to troubleshoot issues:
This will show detailed information about:
- Project detection results
- Package installation steps
- File modifications
- Configuration changes
CI/CD Integration
For automated deployments, use the non-interactive mode:
Set environment variables beforehand:
Next Steps
After running the CLI:
- Start Your Application: Run your application and make LLM calls to see traces in Opik
- Explore Traces: Visit the Opik dashboard to view your traces
- Add Custom Spans: Learn about manual tracing for custom instrumentation
- Set Up Evaluation: Configure evaluation metrics for your LLM outputs
- Production Monitoring: Set up production monitoring for your application