Skip to main content
The Python SDK is a thin convenience layer: it points your OpenAI client at the Orbitrage gateway and tags every request with a trace id. No runtime dependencies, no background threads, no span exporters. Orbitrage is OpenAI-format only — to use Claude, Gemini, Grok, etc., just name the model; you don’t use that provider’s SDK.

PyPI

pip install orbitrage

License

Apache-2.0 · Python 3.9–3.13

Install

openai (>=1.0) is the only peer you need — Orbitrage speaks OpenAI format:

Initialize

Call init() once, at the very top of your program, before importing your LLM client.

What init() does

  1. Generates a stable trace id for the process and adds it to every request as x-orbitrage-run-id, so all your calls group into one run.
  2. Patches the OpenAI and AsyncOpenAI constructors to default base_url to https://api.orbitrage.ai/v1 and inject the trace headers. Your explicit base_url or api_key always wins.
  3. Sets OPENAI_BASE_URL as a safety net for clients constructed with no arguments.
It does not load OpenTelemetry or Traceloop, and it exports nothing — the gateway is the source of truth.

init() parameters

str
required
Your orb_ key. Falls back to ORBITRAGE_API_KEY if omitted.
str
End-user id to attribute calls to (sets x-orbitrage-end-user-id).
str
Override the gateway URL. Defaults to https://api.orbitrage.ai/v1 (or ORBITRAGE_BASE_URL).
bool
default:"True"
Set False to make init() a no-op (e.g. in tests).
bool
default:"False"
Suppress the startup log line.
init() is idempotent — calling it more than once is safe and has no effect after the first call. Legacy v0.4 keyword arguments (disable_batch, capture_content, instruments, …) are accepted and ignored.

Per-end-user attribution

After set_user(), construct a new client for the change to take effect — already-built clients have already copied their headers.

Forcing a model

auto, router, default, and orbitrage all trigger routing. See Routing.
Pinning a frontier model (claude-*, gpt-*, gemini-*, grok-*) requires an enabled key for that vendor — the call runs on your provider account and Orbitrage bills $0. Without one it raises a 403 with code byok_key_required. See BYOK.

API surface

The decorators and lifecycle functions exist so code written for v0.4 keeps importing without changes. The gateway captures the same data regardless of decorator markup.

Observability-only mode

You don’t have to let Orbitrage change your model. Pin explicit models (or use BYOK) and you still get full observability — every call is traced because it flows through the gateway:

Using a framework?

LangChain, LangGraph, CrewAI, Agno, and others use the OpenAI client under the hood, so they’re captured transparently. See Integrations for per-framework setup.