PY

This skill provides standard Python patterns for SDK tracing, flushing, and third-party library integration to maintain performance.

Install

mkdir -p .claude/skills/python-sdk && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1731" && unzip -o skill.zip -d .claude/skills/python-sdk && rm skill.zip

Installs to .claude/skills/python-sdk

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Python SDK patterns for Opik. Use when working in sdks/python, on SDK APIs, integrations, or message processing.
112 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Trace function execution with decorators
  • Configure message batching for efficiency
  • Integrate with third-party libraries via patching
  • Manage SDK API calls
  • Flush operations before exit

How it works

It employs a three-layer architecture that separates public APIs from message processing and REST clients to ensure efficient, batched data transmission.

Inputs & outputs

You give it
SDK integration or tracing request
You get back
Configured SDK code or tracing implementation

When to use python-sdk

  • Implement @opik.track decorators
  • Configure Opik message processing
  • Integrate Opik with LangChain
  • Debug SDK API calls

About this skill

Python SDK

Three-Layer Architecture

Layer 1: Public API      (opik.Opik, @opik.track)
    ↓
Layer 2: Message Processing   (queue, batching, retry)
    ↓
Layer 3: REST Client     (OpikApi, HTTP)

Critical Gotchas

Flush Before Exit

# ✅ REQUIRED for async operations
client = opik.Opik()
# ... tracing operations ...
client.flush()  # Must call before exit!

Async vs Sync Operations

Async (via message queue) - fire-and-forget:

  • trace(), span()
  • log_traces_feedback_scores()
  • experiment.insert()

Sync (blocking, returns data):

  • create_dataset(), get_dataset()
  • create_prompt(), get_prompt()
  • search_traces(), search_spans()

Lazy Imports for Integrations

# ✅ GOOD - integration files assume dependency exists
import anthropic  # Only imported when user uses integration

# ❌ BAD - importing at package level
from opik.integrations import anthropic  # Would fail if not installed

Integration Patterns

Pattern Selection

Library has callbacks? → Pure Callback (LangChain, LlamaIndex)
No callbacks?         → Method Patching (OpenAI, Anthropic)
Callbacks unreliable? → Hybrid (ADK)

Method Patching (OpenAI, Anthropic)

from opik.integrations.anthropic import track_anthropic

client = anthropic.Anthropic()
tracked_client = track_anthropic(client)  # Wraps methods

Callback-Based (LangChain)

from opik.integrations.langchain import OpikTracer

tracer = OpikTracer()
chain.invoke(input, config={"callbacks": [tracer]})

Decorator-Based

@opik.track
def my_function(input: str) -> str:
    # Auto-creates span, captures input/output
    return process(input)

Dependency Policy

  • Avoid adding new dependencies
  • Use conditional imports for integrations
  • Keep version bounds flexible: >=2.0.0,<3.0.0

Batching System

Messages batch together for efficiency:

  • Flush triggers: time (1s), size (100), memory (50MB), manual
  • Reduces HTTP overhead significantly

API Method Naming

# CRUD: create/get/list/update/delete
client.create_experiment(name="exp")
client.get_dataset(name="ds")

# Search for complex queries
client.search_spans(project_name="proj")
client.search_traces(project_name="proj")

# Batch for bulk operations
client.batch_create_items(...)

Reference Files

When not to use it

  • When not using the Opik Python SDK
  • When performing non-async operations that do not require flushing

Prerequisites

Opik Python SDK installed

Limitations

  • Requires explicit flushing for async operations
  • Integration depends on library-specific callback availability

How it compares

It provides standardized patterns for tracing and batching that prevent common performance and data loss issues in Python SDKs.

Compared to similar skills

python-sdk side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
python-sdk (this skill)43moNo flagsIntermediate
langchain-architecture82moReviewIntermediate
voice-ai-development56moNo flagsAdvanced
hugging-face-tool-builder76moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

langchain-architecture

wshobson

Design LLM applications using the LangChain framework with agents, memory, and tool integration patterns. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.

899

voice-ai-development

davila7

Expert in building voice AI applications - from real-time voice agents to voice-enabled apps. Covers OpenAI Realtime API, Vapi for voice agents, Deepgram for transcription, ElevenLabs for synthesis, LiveKit for real-time infrastructure, and WebRTC fundamentals. Knows how to build low-latency, production-ready voice experiences. Use when: voice ai, voice agent, speech to text, text to speech, realtime voice.

553

hugging-face-tool-builder

patchy631

Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful when chaining or combining API calls or the task will be repeated/automated. This Skill creates a reusable script to fetch, enrich or process data.

714

serving-llms-vllm

davila7

Serves LLMs with high throughput using vLLM's PagedAttention and continuous batching. Use when deploying production LLM APIs, optimizing inference latency/throughput, or serving models with limited GPU memory. Supports OpenAI-compatible endpoints, quantization (GPTQ/AWQ/FP8), and tensor parallelism.

66

azure-ai-contentunderstanding-py

microsoft

Azure AI Content Understanding SDK for Python. Use for multimodal content extraction from documents, images, audio, and video. Triggers: "azure-ai-contentunderstanding", "ContentUnderstandingClient", "multimodal analysis", "document extraction", "video analysis", "audio transcription".

12

azure-speech-to-text-rest-py

microsoft

Azure Speech to Text REST API for short audio (Python). Use for simple speech recognition of audio files up to 60 seconds without the Speech SDK. Triggers: "speech to text REST", "short audio transcription", "speech recognition REST API", "STT REST", "recognize speech REST". DO NOT USE FOR: Long audio (>60 seconds), real-time streaming, batch transcription, custom speech models, speech translation. Use Speech SDK or Batch Transcription API instead.

11

Search skills

Search the agent skills registry