Skip to main content
Switch from OpenAI to Auriko in 3 lines of code. Your existing chat completions, streaming, and tool calling code works without changes.

Before and after

# Before (OpenAI)
from openai import OpenAI
client = OpenAI(api_key="sk-...")

# After (Auriko)
import os
from auriko import Client
client = Client(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

# Everything else stays the same
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

What works identically

All standard OpenAI API features work through Auriko with no code changes:
FeatureStatus
Chat completionsFully compatible
StreamingFully compatible
Tool callingFully compatible
Structured outputFully compatible
Models listFully compatible
Async clientFully compatible
Error classesFully compatible
Retry logicBuilt-in (max 2 retries, exponential backoff)

What’s new

Auriko adds capabilities on top of the OpenAI-compatible interface:
  • Routing options — optimize for cost, speed, or throughput across providers. See Routing options.
  • Cost optimization — save 30-70% by routing to the cheapest provider. See Cost optimization.
  • Prompt caching — automatic cache injection for all supported providers. See Prompt caching.
  • Budget management — set spending limits per workspace, API key, or BYOK provider. See Budget management.
  • Response headers — every response carries request_id, rate limit headers, and credit usage. See Python SDK.

Use OpenAI SDK directly

You don’t need the auriko package at all. The OpenAI SDK works with a base_url override:
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

response = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Hello from Claude via Auriko!"}]
)
print(response.choices[0].message.content)
This approach lets you access any model from any provider (Anthropic, Google, Meta, and more) through the familiar OpenAI client.

Error mapping

When using the OpenAI SDK directly, convert errors to typed Auriko errors with map_openai_error():
import os
import openai
from auriko import map_openai_error, RateLimitError, BudgetExceededError

client = openai.OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

try:
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Hello!"}]
    )
except openai.APIStatusError as e:
    auriko_error = map_openai_error(e)
    if isinstance(auriko_error, RateLimitError):
        print(f"Rate limited. Retry after: {auriko_error.response_headers.rate_limit_reset}")
    elif isinstance(auriko_error, BudgetExceededError):
        print(f"Budget exceeded: {auriko_error.message}")
    else:
        raise auriko_error
map_openai_error() is Python-only. See Error Handling for the full error handling guide.

Access routing metadata

When using the OpenAI SDK directly, extract routing metadata from responses with parse_routing_metadata():
from auriko.route_types import parse_routing_metadata

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
metadata = parse_routing_metadata(response)
if metadata:
    print(f"Provider: {metadata.provider}")
    if metadata.cost:
        print(f"Cost: ${metadata.cost.billable_cost_usd}")
parse_routing_metadata() is Python-only. The Auriko SDK exposes routing_metadata as a typed property on ChatCompletion and Stream directly. Use the native SDK for the best experience.
For the full native SDK experience with typed responses and errors, see the Python SDK Guide or TypeScript SDK Guide.