comet-ml/opik-skills

opik

Reference for the Opik SDK — tracing, span types, framework integrations, threads, and the prompt library (Python, TypeScript, REST).

First seen Mar 30, 2026

Installation

$ npx skills add comet-ml/opik-skills --skill opik

Summary

  • Reference for the Opik SDK — tracing, span types, framework integrations, threads, and the prompt library (Python, TypeScript, REST).
  • Use for "what span types exist", "how do I flush", "track_openai", "add OpikTracer", "version a prompt".
  • To instrument a repo end to end, use the `opik-instrument` skill.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from comet-ml/opik-skills · top by installs.

npx skills add comet-ml/opik-skills

Browse all from comet-ml/opik-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 7
License LICENSE
Default branch main
Open issues 0
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

More metadata
last_updated
2026-09-08
source_commit
TODO — pin to the Opik release this was verified against (OPIK-7471)

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 6,659 B
  • docs SUMMARY.md 315 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 461 installs

SKILL.md

Opik SDK Reference

Opik is an open-source LLM observability platform. This skill is a reference for the SDK. To instrument a codebase step by step (detect frameworks, add config, emit and verify a trace), use the task-shaped opik-instrument skill.

Core concepts

A trace is one execution path (one request → one response). Spans are the operations inside it and form a hierarchy.

Span types — the ONLY valid values

Type Use for
general orchestration, agent entry points
llm model calls
tool tools, retrieval, API / DB calls
guardrail safety / validation checks

Do NOT use retrieval or any other value.

Python — tracing

import opik

@opik.track(name="agent", type="general")
def agent(query: str) -> str:
    return generate(retrieve(query))

@opik.track(type="tool")
def retrieve(query): ...

@opik.track(type="llm")
def generate(ctx): ...

opik.flush_tracker()   # required in scripts

TypeScript — tracing

import { Opik } from "opik";
const client = new Opik({ projectName: "my-project" });

const trace = client.trace({ name: "agent", input: { query } });
const span = trace.span({ name: "llm-call", type: "llm" });
span.end({ output });
trace.end({ output });
await client.flush();

Framework integrations

Prefer an integration over manual @opik.track — integrations capture tokens, model, and cost automatically. Patterns (full list in references/integrations.md):

  • wrap-the-clienttrackopenai(OpenAI()), trackanthropic(...)
  • global-enabletrack_crewai(crew=crew)
  • callbackdspy.configure(callbacks=[OpikCallback()])
  • tracerOpikTracer() for LangChain / LangGraph / LlamaIndex
  • agent-specifictrackadkagent_recursive(agent, OpikTracer())

LiteLLM inside @opik.track (common trap)

If code uses litellm and you add @opik.track, pass currentspandata via metadata on every completion call — otherwise OpikLogger emits orphaned top-level traces instead of nesting under your span.

from opik.opik_context import get_current_span_data

@opik.track
def call_llm(messages):
    return litellm.completion(
        model="gpt-4o", messages=messages,
        metadata={"opik": {"current_span_data": get_current_span_data()}},
    )

Threads (conversations)

Group turns with threadid — one turn = one trace, shared threadid = one thread. Use for chat / multi-turn; skip for single-shot.

@opik.track(entrypoint=True)
def handle(session_id: str, message: str) -> str:
    opik.update_current_trace(thread_id=session_id)
    return reply(message)

Prompt library

Version prompts with client.getprompt / createprompt (chat variants: getchatprompt / createchatprompt). Store model + temperature in the prompt metadata so they version with the text. Call get_prompt inside a @opik.track function so the version links to the trace.

@opik.track(entrypoint=True)
def run(question: str) -> str:
    p = client.get_prompt(name="system") or client.create_prompt(
        name="system",
        prompt="You help with {{product}}.",
        metadata={"model": "gpt-4o", "temperature": 0.7},
    )
    return llm(p.format(product="Opik"), model=p.metadata["model"])

Searching traces

One filter grammar, OQL, serves both the hosted MCP's list tool and the SDK's searchtraces / searchspans / search_threads:

<field>[.<key>] <op> <value> [AND ...]
ops: = != > >= < <= contains not_contains starts_with ends_with is_empty is_not_empty in not_in

Strings in double quotes, numbers bare, duration in milliseconds, dates as ISO-8601 instants with a timezone ("2026-09-08T10:00:00Z"). Scores and dictionaries take a key: feedback_scores.accuracy < 0.5, metadata.environment = "prod". AND is the only connector.

error_info is_not_empty AND duration > 5000
type = "llm" AND usage.total_tokens > 10000            # spans
feedback_scores.hallucination > 0.5 AND start_time >= "2026-09-08T00:00:00Z"

With the MCP connected, prefer list — it also sorts (sort="duration desc"), windows (since="1h", "7d"), and searches free text (search="order-42"):

list(entity_type="trace", project_name="<project>", since="1h",
     filters="error_info is_not_empty", sort="duration desc")

Trace, span and thread lists add source = "sdk" unless you name source, so evaluator, playground and experiment traces stay out of the way. A rejected filter comes back with what fixes it; schema("list.trace") (or list.span, list.thread, list.experiment) is the full field and operator reference.

Without the MCP, the same string goes to the SDK:

client.search_traces(project_name="<project>", filter_string="error_info is_not_empty")

Anti-patterns

Anti-pattern Fix
span type retrieval / custom use tool (or general)
get_prompt outside @opik.track fetch inside — else no trace link
deprecated opik.Prompt / opik.Config use client.get_prompt / config file
litellm without currentspandata pass it — else orphaned traces
no flush in scripts opik.flush_tracker() / await client.flush()

References

Topic File
Python SDK (async, distributed, context) references/tracing-python.md
TypeScript SDK references/tracing-typescript.md
REST API references/tracing-rest-api.md
All integrations references/integrations.md
Core concepts (traces, spans, threads) references/observability.md
Best practices (lifecycle, monitoring, anti-patterns) references/best-practices.md
Agent architecture, reliability, security references/agent-patterns.md
Production monitoring, alerts, guardrails references/production.md
Evaluation datasets & test suites (reference) references/evaluation-datasets.md, references/evaluation-test-suites.md

To build and run an evaluation, use the opik-evaluate skill. For repo instrumentation and config, use the opik-instrument skill.