Skip to main content
The Python SDK (opentracy) is the native entry point. Use it if you’re starting a new project or if you want features (auto-routing, distillation, trace ingestion) that aren’t part of the OpenAI API shape.

Install

One install pulls a platform-specific wheel with the Go engine binary, the ONNX embedder, and pre-trained routing weights bundled in. No extras needed for the core path.

The four things you’ll do

1. One-off completion

Just a chat completion, no routing, no trace.
Full API: completion reference.

2. Explicit router with fallbacks

When you want deterministic rules (“try GPT-4o first, then Claude, then DeepSeek”), use the Router class:
Full API: Router reference.

3. Semantic auto-router

Load the pre-trained router once; it picks the right model per prompt:
Combined with ot.completion this becomes a cost-optimizing client:
Full API: load_router reference.

4. Distillation

The one-call path — ot.distill() runs the full 4-phase pipeline in-process and returns a callable Student. Needs opentracy[distill] and a CUDA GPU.
Full API: ot.distill reference. For the long-running, queued REST flow against a self-hosted engine (ClickHouse-backed jobs, UI observability), use Distiller instead — same engine, different deployment shape.

Async

Everything that has a sync version has async:
acompletion shares its request-preparation path with the sync version, so force_engine, force_direct, fallbacks, and engine-prefix handling all behave identically.

Trace ingestion

If you have existing logs from another LLM provider and want to use them for dataset building or distillation in OpenTracy, you can import them directly:

Engine routing opt-in

By default the SDK calls providers directly. To route through an OpenTracy engine (for observability, aliases, etc.), set the env var once:
From that point on, ot.completion(...) routes through the engine. Per-call overrides:
Why isn’t this automatic? Because silently routing through whatever happens to be listening on localhost:8080 is a footgun. Opt-in is explicit.

13 providers via create_client

If you want a first-class LLMClient object (for profiling, or to fit into custom routing code), create_client covers every provider:
Five providers have dedicated classes (OpenAI, Anthropic, Google, Groq, Mistral); the remaining seven (DeepSeek, Perplexity, Cerebras, Sambanova, Together, Fireworks, Cohere) route through a UnifiedClient that speaks the OpenAI-chat protocol. Bedrock is registered but raises a clear error on construction — AWS SigV4 is not handled by UnifiedClient yet; use ot.completion(force_engine=True) instead.

Public API

Everything import opentracy as ot exposes publicly:
Lazy research APIs (load_router, UniRouteRouter, RouterEvaluator, LLMJudge, …) resolve via __getattr__ — they import the first time you touch them, so they don’t slow down the initial import opentracy.
Legacy code using import lunar_router as lr keeps working via a backwards-compat shim that redirects to opentracy and emits a DeprecationWarning. New code should use import opentracy as ot.

Next

Self-host

Run engine + ClickHouse + UI locally or in your cloud.

API Reference

Every parameter and return value.