npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opik-vercel

v1.11.11

Published

Opik TypeScript and JavaScript SDK integration with Vercel AI SDK

Readme

Opik Vercel AI SDK Integration

npm version License

Seamlessly integrate Opik observability with your Vercel AI SDK applications to trace, monitor, and debug your AI workflows.

Features

  • 🔍 Comprehensive Tracing: Automatically trace AI SDK calls and completions
  • 📊 Hierarchical Visualization: View your AI execution as a structured trace with parent-child relationships
  • 📝 Detailed Metadata Capture: Record model names, prompts, completions, token usage, and custom metadata
  • 🚨 Error Handling: Capture and visualize errors in your AI API interactions
  • 🏷️ Custom Tagging: Add custom tags to organize and filter your traces
  • 🔄 Streaming Support: Full support for streamed completions and chat responses

Installation

Node.js

npm install opik-vercel ai @ai-sdk/openai @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node

Next.js

npm install opik-vercel @vercel/otel @opentelemetry/api-logs @opentelemetry/instrumentation @opentelemetry/sdk-logs

Requirements

  • Node.js ≥ 18
  • Vercel AI SDK (ai ≥ 3.0.0)
  • Opik SDK (automatically installed as a peer dependency)
  • OpenTelemetry packages (see installation commands above)

Configuration

Set your environment variables:

OPIK_API_KEY="<your-api-key>"
OPIK_URL_OVERRIDE="https://www.comet.com/opik/api"  # Cloud version
OPIK_PROJECT_NAME="<custom-project-name>"
OPIK_WORKSPACE="<your-workspace>"
OPENAI_API_KEY="<your-openai-api-key>"  # If using OpenAI models

Usage

Node.js

import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { OpikExporter } from "opik-vercel";

const sdk = new NodeSDK({
  traceExporter: new OpikExporter(),
  instrumentations: [getNodeAutoInstrumentations()],
});

sdk.start();

async function main() {
  const result = await generateText({
    model: openai("gpt-5-nano"),
    maxTokens: 50,
    prompt: "What is love?",
    experimental_telemetry: OpikExporter.getSettings({
      name: "opik-nodejs-example",
    }),
  });

  console.log(result.text);

  await sdk.shutdown(); // Flushes the trace to Opik
}

main().catch(console.error);

Next.js

For Next.js applications, use the framework's built-in OpenTelemetry support:

// instrumentation.ts
import { registerOTel } from "@vercel/otel";
import { OpikExporter } from "opik-vercel";

export function register() {
  registerOTel({
    serviceName: "opik-vercel-ai-nextjs-example",
    traceExporter: new OpikExporter(),
  });
}

Then use the AI SDK with telemetry enabled:

import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";

const result = await generateText({
  model: openai("gpt-5-nano"),
  prompt: "What is love?",
  experimental_telemetry: { isEnabled: true },
});

Advanced Configuration

Custom Tags and Metadata

You can add custom tags and metadata to all traces generated by the OpikExporter:

const exporter = new OpikExporter({
  // Optional: add custom tags to all traces
  tags: ["production", "gpt-5-nano"],
  // Optional: add custom metadata to all traces
  metadata: {
    environment: "production",
    version: "1.0.0",
    team: "ai-team",
  },
  // Optional: associate traces with a conversation thread
  threadId: "conversation-123",
});

Tags are useful for filtering and grouping traces, while metadata adds additional context for debugging and analysis. The threadId parameter is useful for tracking multi-turn conversations or grouping related AI interactions.

Telemetry Settings

Use OpikExporter.getSettings() to configure telemetry for individual AI SDK calls:

const result = await generateText({
  model: openai("gpt-5-nano"),
  prompt: "Tell a joke",
  experimental_telemetry: OpikExporter.getSettings({
    name: "custom-trace-name",
    // Optional: set threadId per request (overrides exporter-level threadId)
    metadata: {
      threadId: "conversation-456",
    },
  }),
});

Or use the basic telemetry settings:

const result = await generateText({
  model: openai("gpt-5-nano"),
  prompt: "Tell a joke",
  experimental_telemetry: { isEnabled: true },
});

Viewing Traces

To view your traces:

  1. Sign in to your Comet account
  2. Navigate to the Opik section
  3. Select your project to view all traces
  4. Click on a specific trace to see the detailed execution flow

Debugging

To enable more verbose logging for troubleshooting:

OPIK_LOG_LEVEL=DEBUG

Learn More

License

Apache 2.0