Stop the LLM Bill Shock. Production-grade observability for Go backends — built on OpenTelemetry.
Most LLM observability tools tell you what you spent after the money is gone. In production, a recursive prompt loop or a single "power user" can rack up thousands in costs before your billing alerts even trigger.
Otellix is different. It brings real-time cost enforcement to the application layer.
- 🧩 One-Line SDK Middleware: Already using the official OpenAI or Anthropic Go SDK? Add
option.WithMiddleware(otellixopenai.Middleware(...))and every call is traced, costed and budgeted. Your calls don't change. - ⛓️ LangChainGo Integration: Drop-in
callbacks.Handlerfor LangChainGo. Automatic token, cost, and span capture for chains. - 🔌 Zero-Config Attribution: Automatically capture
user_idandproject_idfrom Gin, Echo or Fiber middleware. No more manual context plumbing. - 🗄️ Redis Budget Store: Distributed budget enforcement for high-availability production clusters.
- 🚀 Go-Native & High-Performance: Built for Go 1.22+ using native streaming and OpenTelemetry.
- 📊 Standard-Compliant (OTel): 100% OTel compliant. Works with Jaeger, Honeycomb, Prometheus, and Grafana.
- 💎 Prompt Caching ROI: Track exactly how much you save with Anthropic/OpenAI prompt caching.
go get github.com/oluwajubelo1/otellixWant to see the full stack (Prometheus + Grafana) in action? Run our one-liner demo:
curl -sL https://raw.githubusercontent.com/oluwajubelo1/otellix/main/scripts/demo.sh | bashWrap your provider calls to get instant cost attribution and standard OTel spans.
p := openai.New()
result, err := otellix.Trace(ctx, p, params,
otellix.WithUserID("user_456"),
)Just add the Otellix handler to your LLM configuration.
import "github.com/oluwajubelo1/otellix/integrations/langchaingo"
handler := langchaingo.NewOtellixHandler(
langchaingo.WithProvider("openai"), // required for accurate llm.cost_usd
langchaingo.WithModel("gpt-4o"),
)
p, _ := openai.New(openai.WithCallback(handler))
// Automatically captures token usage, cost, and spans.
res, err := p.GenerateContent(ctx, parts)The handler records llm.* attributes on a span in the context, or creates its
own llm.call span if none exists, so telemetry is always captured. Set
WithProvider/WithModel (LangChainGo doesn't expose them in its callbacks)
to enable cost tracking.
Stop manually passing IDs. Use our middleware to discover identity from headers/JWTs.
import otellixmw "github.com/oluwajubelo1/otellix/middleware"
r := gin.Default()
r.Use(otellixmw.GinMiddleware()) // Automatically populates context with User/Project IDsTwo dev modes help you see traces while building:
shutdown := otellix.SetupDev() // (1) Pretty summary + raw OTel span JSON
defer shutdown()
shutdown := otellix.SetupDevConsole() // (2) Pretty summary only — clean terminal
defer shutdown()SetupDev()configures an OpenTelemetry stdout trace exporter (human-readable summary and the raw span JSON) — best for inspecting the exact span payload.SetupDevConsole()prints only the one-line[otellix]summary per call and leaves your existingTracerProvideruntouched — ideal for demos and presentations.RegisterDevPrinter()enables just the summary printer when you already have your ownTracerProviderconfigured.
Otellix populates your spans with industry-standard attributes:
| Attribute | Description |
|---|---|
llm.provider |
The LLM provider (OpenAI, Anthropic, etc.) |
llm.model |
The model used (e.g. claude-sonnet-4-6) |
llm.input_tokens / llm.output_tokens |
Token usage for the call |
llm.cache_read_tokens |
Tokens served from provider cache (Savings!) |
llm.cost_usd |
Real-time USD cost of the call |
Provider wrappers (drop-in Call/Stream):
- Anthropic: Claude Opus/Sonnet/Haiku families with full Prompt Caching metrics.
- OpenAI: GPT-5.x, GPT-4.x, o-series, gpt-oss with caching support.
- Google Gemini: Gemini 3.x, 2.5, 2.0 & 1.5 Pro/Flash.
- Ollama: Local models with zero-dependency streaming.
Pricing-only support (built-in cost table for llm.cost_usd; bring your own provider/API): Kimi (Moonshot), DeepSeek, Qwen, GLM, ERNIE, Hunyuan, Mistral, Grok, plus every model above — 130+ models total. See docs/providers.md.
- Architecture — How Otellix fits into the OTel ecosystem.
- Budget Guardrails — Limits, fallback actions, Redis & InMemory stores.
- Budget Reservations & Cost Estimates — Keeping concurrent calls within a limit, and how costs are estimated.
- Budget Windows — Rolling, daily and monthly budgets, time zones and resets.
- Unpriced Models — Making sure models with no price still count against budgets.
- Cost Attribution — Who spent what, and capping calls with no user.
- Metric Labels & Cardinality — Dropping the
user_idlabel so metrics scale to many users. - SDK Middleware — Trace and budget existing OpenAI and Anthropic SDK clients with one option.
- Integrations — LangChainGo setup.
- Middleware & Identity — Gin, Echo and Fiber attribution, verified identity.
- Prompt Caching — ROI analysis and tracking.
- Request Deduplication — One provider call for repeated and concurrent identical requests.
We love stars and contributions! Please see CONTRIBUTING.md. Licensed under MIT.
