Back to GuidesDeveloper

Cloptima LLM Observability SDKs (JS, Python, Go)

7 min readUpdated June 2026

When to use the SDK

Use the SDK when you want attribution and cost telemetry but aren't ready to route traffic through the gateway. You keep your own provider client, retries, and auth; Cloptima receives usage and ownership metadata. If configuration is missing, the SDK returns a disabled pass-through so local dev and tests never break.

Install

First-class SDKs are available for three ecosystems:

# JavaScript / TypeScript
npm install @cloptima/llm-observability        # github.com/cloptima/llm-observability-js

# Python (3.9+)
pip install cloptima-llm-observability         # github.com/cloptima/llm-observability-python

# Go (1.21+)
go get github.com/cloptima/llm-observability-go

Instrument a call

Wrap the call you already make. observeCall captures provider, model, token usage, latency, and your attribution context. createObservedCall and wrapObservedService help you instrument reusable wrappers and service classes.

import { initFromEnv, extractOpenAIUsage } from "@cloptima/llm-observability";

const cloptima = initFromEnv(); // reads CLOPTIMA_LLM_OBSERVABILITY_API_KEY / _APP_ID / _ENVIRONMENT

const result = await cloptima.observeCall({
  provider: "openai",
  model: "gpt-4.1-mini",
  call: () => summaryService.generate(prompt),
  extractUsage: extractOpenAIUsage,
  featureId: "summary_generation",
  workflowId: "support_agent",
});

Attribute with rich and custom dimensions

Beyond team, app, feature, workflow, environment, session, and run, the SDKs accept business and custom dimensions — tenant, customer, cost center, business unit — plus a free-form metadata/attributes bag for anything specific to your product. Those dimensions flow straight into the spend explorer and unit economics.

  • Built-in: team, app, feature, workflow, environment, session, run, developer
  • Business: tenantId, customerId, costCenter, businessUnit, business transaction value/units
  • Custom: arbitrary metadata / attributes for your own dimensions

Where it sends data

The SDK sends bearer-authenticated HTTPS to https://api.cloptima.ai/v1/ai/integrations/sdk/events. It's non-blocking by default, so it won't add latency to your request path.

Put This Guide Into Practice

Cloptima automates the strategies described in this guide.

No credit card required
5-minute setup
Free trial