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:

$npx opik-configure

The CLI will guide you through:

  1. Project Detection: Identifies your package manager and project structure
  2. Dependency Installation: Installs Opik SDK and integration packages
  3. Environment Setup: Configures API keys and environment variables
  4. Code Generation: Sets up Opik client in your root project folder
  5. 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:

OptionTypeDefaultDescriptionEnvironment Variable
--helpboolean-Display help information-
--versionboolean-Show version number-
--debugbooleanfalseEnable verbose logging for troubleshootingOPIK_CONFIGURE_DEBUG
--defaultbooleantrueUse default options for all prompts (non-interactive)OPIK_CONFIGURE_DEFAULT
--force-installbooleanfalseForce package installation even if peer dependency checks failOPIK_CONFIGURE_FORCE_INSTALL
--install-dirstringcurrent directorySpecify custom installation directoryOPIK_CONFIGURE_INSTALL_DIR

Examples

Verbose debugging mode:

$npx opik-configure --debug

Non-interactive mode with defaults:

$npx opik-configure --default

Install in a specific directory:

$npx opik-configure --install-dir=./my-app

Force installation (skip peer dependency checks):

$npx opik-configure --force-install

Environment Configuration

The CLI automatically creates or updates your .env file with the necessary configuration:

$# Opik Configuration
>OPIK_API_KEY=your-api-key-here
>OPIK_URL_OVERRIDE=https://www.comet.com/opik/api
>OPIK_PROJECT_NAME=default
>OPIK_WORKSPACE_NAME=default

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:

$# Use --force-install to bypass peer dependency checks
>npx opik-configure --force-install

Package Manager Issues

If the CLI fails to detect your package manager:

  1. Ensure you have a package.json in your project directory
  2. Try running the CLI with debug mode: npx opik-configure --debug
  3. Manually specify your package manager by selecting it from the prompts

Environment Variable Setup

If environment variables aren’t being set correctly:

  1. Check that .env file was created in your project root
  2. Ensure your application loads environment variables (e.g., using dotenv)
  3. Restart your development server after running the CLI

Integration Not Working

If traces aren’t appearing in Opik:

  1. Verify your OPIK_API_KEY is correct
  2. Check that OPIK_URL_OVERRIDE points to the right endpoint
  3. Ensure you’re calling flush() before your application exits:
    1await trackedClient.flush();

Debug Mode

Enable verbose logging to troubleshoot issues:

$npx opik-configure --debug

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:

$# In your CI/CD pipeline
>npx opik-configure --default --force-install

Set environment variables beforehand:

$export OPIK_API_KEY="your-api-key"
>export OPENAI_API_KEY="your-openai-key"
>npx opik-configure --default

Next Steps

After running the CLI:

  1. Start Your Application: Run your application and make LLM calls to see traces in Opik
  2. Explore Traces: Visit the Opik dashboard to view your traces
  3. Add Custom Spans: Learn about manual tracing for custom instrumentation
  4. Set Up Evaluation: Configure evaluation metrics for your LLM outputs
  5. Production Monitoring: Set up production monitoring for your application

Further Resources