Typescript sdk

From comet-ml/opik · View interactive version

Typescript sdk is an AI agent skill from the GitHub repository comet-ml/opik. TypeScript SDK patterns for Opik. Use when working in sdks/typescript.

How to use this skill

Skill file

TypeScript SDK

Architecture

Layer Flow

Public API → OpikClient → Domain (Trace/Span) → BatchQueues → REST Client → Backend

Critical Gotchas

Flush Before Exit

// ✅ REQUIRED - especially in CLI/tests
await client.flush();
// or globally:
await flushAll();

Domain Objects Don't Do HTTP

// ✅ GOOD - domain objects enqueue, not HTTP
trace.update({ metadata: { key: 'value' } }); // Enqueues update
trace.end();  // Enqueues update

// ❌ BAD - don't call REST directly from domain

Never Leak rest_api

// ✅ GOOD - export from public API
export { Opik, track, flushAll } from 'opik';

// ❌ BAD - don't expose generated clients
import { TracesApi } from 'opik/rest_api';  // Internal!

Batching Semantics

Error Handling

Integration Guidelines

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.