> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://www.comet.com/docs/opik/reference/typescript-sdk/overview/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://www.comet.com/_mcp/server. # Opik TypeScript SDK The Opik TypeScript SDK provides a powerful and easy-to-use interface for tracing, monitoring, and debugging your JavaScript and TypeScript applications. It offers comprehensive observability for LLM applications, agent workflows, and AI-powered systems. ## Integrations Opik provides seamless integrations with popular JavaScript/TypeScript frameworks and libraries: **Frameworks:** * **[Agno](/integrations/agno)** - Trace and monitor your Agno AI agent applications * **[BeeAI](/integrations/beeai)** - Trace and monitor your BeeAI agent applications * **[LangChain](/integrations/langchainjs)** - Trace and monitor your LangChain applications, including chains, agents, tools, and retrievers * **[Mastra](/integrations/mastra)** - Trace and monitor your Mastra AI applications * **[Vercel AI SDK](/integrations/vercel-ai-sdk)** - Integrate Opik with Vercel AI SDK for monitoring AI-powered applications **Model Providers:** * **[Cloudflare Workers AI](/integrations/cloudflare-workers-ai)** - Trace and monitor your Cloudflare Workers AI applications * **[Gemini](/integrations/gemini-typescript)** - Trace and monitor your applications using the Google Generative AI Node.js SDK * **[OpenAI](/integrations/openai-typescript)** - Trace and monitor your applications using the official OpenAI Node.js SDK For a complete list of TypeScript/JavaScript integrations and other language integrations, see the [Integrations Overview](/integrations/overview). ## Installation ### Option 1: Using the Opik TS (Recommended) The fastest way to get started is using the [Opik TS](/reference/typescript-sdk/opik-ts), an interactive CLI tool that sets up Opik automatically in your project: ```bash npx opik-ts configure ``` The CLI will: * Detect your project setup * Install Opik SDK and integration packages * Configure environment variables * Set up Opik client for your LLM integrations ### Option 2: Manual Installation You can also install the `opik` package manually using your favorite package manager: ```bash npm install opik ``` ## Opik Configuration You can configure the Opik client using environment variables. ```bash export OPIK_API_KEY="your-api-key" # If running on Opik Cloud export OPIK_URL_OVERRIDE="https://www.comet.com/opik/api" # If running locally export OPIK_URL_OVERRIDE="http://localhost:5173/api" export OPIK_PROJECT_NAME="your-project-name" export OPIK_WORKSPACE="your-workspace-name" ``` Or you can pass the configuration to the Opik client constructor. ```typescript import { Opik } from "opik"; const client = new Opik({ apiKey: "", apiUrl: "https://www.comet.com/opik/api", projectName: "", workspaceName: "", }); ``` ## Usage > **Tip** > > You can find the full Typescript reference documentation > [here](https://www.jsdocs.io/package/opik). ```typescript import { Opik } from "opik"; // Create a new Opik client with your configuration const client = new Opik(); // Log 10 traces for (let i = 0; i < 10; i++) { const someTrace = client.trace({ name: `Trace ${i}`, input: { prompt: `Hello, world! ${i}`, }, output: { response: `Hello, world! ${i}`, }, }); // For each trace, log 10 spans for (let j = 0; j < 10; j++) { const someSpan = someTrace.span({ name: `Span ${i}-${j}`, type: "llm", input: { prompt: `Hello, world! ${i}:${j}`, }, output: { response: `Hello, world! ${i}:${j}`, }, }); // Some LLM work await new Promise((resolve) => setTimeout(resolve, 100)); // Mark the span as ended someSpan.end(); } // Mark the trace as ended someTrace.end(); } // Flush the client to send all traces and spans await client.flush(); ``` > Debug, evaluate, and monitor your LLM applications, RAG systems, and agentic workflows with comprehensive tracing, automated evaluations, and production-ready dashboards.