Skip to main content
The OpenLIT Go SDK provides OpenTelemetry-native observability for Go applications using LLM APIs. It wraps your provider clients with lightweight instrumentation that automatically collects traces, metrics, and cost data without requiring any changes to your application logic.

Supported providers

OpenAI

Chat completions, streaming, embeddings, and image generation — with full token usage and cost tracking.

Anthropic

Claude messages and streaming — with cache token tracking and full OpenTelemetry semantic conventions.

What gets collected

Every instrumented call automatically records:
  • Distributed traces — spans with request/response details, model name, token counts, and cost
  • OTel metricsgen_ai.client.token.usage, gen_ai.client.operation.duration, gen_ai.server.time_to_first_token, gen_ai.server.time_per_output_token, gen_ai.server.request.duration
  • Streaming metrics — time-to-first-chunk and per-chunk latency observations
  • Cost tracking — automatic cost calculation using the built-in pricing data

Installation

Quick start

Replace YOUR_OTEL_ENDPOINT with the URL of your OpenTelemetry backend, such as http://127.0.0.1:4318 for a local OpenLIT deployment.

Configuration

Pass a Config struct to openlit.Init():

Via environment variable

Getting started

OpenAI Integration

Monitor chat completions, streaming, embeddings, and image generation

Anthropic Integration

Monitor Claude messages and streaming with cache token tracking

Destinations

Send telemetry to Datadog, Grafana, New Relic, and other observability stacks

Configuration

Configure the OpenLIT SDK according to your requirements