Go Opik SDK¶
Go SDK for Opik - an open-source LLM observability platform by Comet ML.
Features¶
- Tracing: Create traces and spans to monitor LLM application execution
- Context Propagation: Automatic parent-child relationships using Go context
- Distributed Tracing: Propagate traces across service boundaries
- Datasets: Manage evaluation datasets with CRUD operations
- Experiments: Run and track evaluation experiments
- Prompts: Version-controlled prompt templates with variable substitution
- Evaluation Framework: Heuristic and LLM-based metrics for output evaluation
- LLM Integrations: Auto-tracing for OpenAI, Anthropic, and gollm
- CLI Tool: Command-line interface for management tasks
Quick Start¶
package main
import (
"context"
"log"
opik "github.com/agentplexus/go-opik"
)
func main() {
// Create client (uses OPIK_API_KEY and OPIK_WORKSPACE env vars)
client, err := opik.NewClient(
opik.WithProjectName("My Project"),
)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Create a trace
trace, _ := client.Trace(ctx, "my-trace",
opik.WithTraceInput(map[string]any{"prompt": "Hello"}),
)
// Create a span for an LLM call
span, _ := trace.Span(ctx, "llm-call",
opik.WithSpanType(opik.SpanTypeLLM),
opik.WithSpanModel("gpt-4"),
)
// Do your LLM call here...
// End span with output
span.End(ctx, opik.WithSpanOutput(map[string]any{"response": "Hi!"}))
// End trace
trace.End(ctx)
}
Installation¶
go get github.com/agentplexus/go-opik
Next Steps¶
- Installation & Configuration - Set up the SDK
- Traces and Spans - Learn the core concepts
- Evaluation Framework - Evaluate LLM outputs
- Integrations - Auto-trace OpenAI, Anthropic, and more
- Testing - Run the test suite (no API key required)