Auriko API client - Intelligent LLM routing
Project description
Auriko Python SDK
Type-safe Python SDK for the Auriko intelligent LLM routing API.
Overview
Auriko provides a unified API for accessing multiple LLM providers with intelligent routing based on cost, latency, throughput, and availability. The API is fully compatible with OpenAI's Chat Completions API.
Two ways to use Auriko:
- OpenAI SDK (drop-in) — change
base_urlandapi_key, everything else works as-is - Auriko SDK (native) — typed access to Auriko-specific features: multi-model routing, routing metadata, cost tracking, and more
Installation
pip install auriko
Quick Start with OpenAI SDK
import os
import openai
client = openai.OpenAI(
base_url="https://api.auriko.ai/v1",
api_key=os.environ["AURIKO_API_KEY"],
)
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "What is inference arbitrage?"}],
)
print(response.choices[0].message.content)
Quick Start with Auriko SDK
from auriko import Client
client = Client() # reads AURIKO_API_KEY from environment
# Non-streaming
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Async
import asyncio
from auriko import AsyncClient
async def main():
client = AsyncClient() # reads AURIKO_API_KEY from environment
response = await client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
asyncio.run(main())
Authentication
The SDK reads AURIKO_API_KEY from the environment:
client = Client()
Or pass it explicitly:
client = Client(api_key="ak_...")
The SDK resolves the API key in this order:
api_keyconstructor argumentAURIKO_API_KEYenvironment variable- Raises
AuthenticationError
Auriko Extensions
Beyond OpenAI compatibility, the Auriko SDK provides:
Multi-model routing
response = client.chat.completions.create(
messages=[{"role": "user", "content": "Hello!"}],
gateway={
"models": ["gpt-4o", "claude-sonnet-4-6", "deepseek-chat"],
"routing": {"optimize": "cost"},
},
)
Routing metadata
stream = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
stream=True,
)
for chunk in stream:
pass # consume stream
print(stream.routing_metadata) # provider, model, latency, cost
print(stream.usage) # token counts
Responses (Response API)
response = client.responses.create(
model="gpt-5.4",
input="What is inference arbitrage?",
)
print(response.output_text)
# Streaming
stream = client.responses.create(
model="gpt-5.4",
input="Tell me a story.",
stream=True,
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
Reasoning effort
response = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Think step by step."}],
reasoning_effort="high",
)
Provider extensions
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello"}],
extensions={"openai": {"logit_bias": {"1234": -100}}},
)
Strict parameter routing
Only route to providers that support the optional parameters you sent:
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
seed=42,
gateway={"routing": {"require_parameters": True}},
)
See Filter by parameter support for the full list of parameters this applies to.
Available Resources
| Resource | Methods | Auth |
|---|---|---|
client.chat.completions |
create() |
API key |
client.responses |
create() |
API key |
client.models |
list_directory(), list_registry(), list_providers() |
Public |
client.me |
get() |
API key |
Configuration
client = Client(
api_key="ak_...", # default: AURIKO_API_KEY env var
base_url="https://api.auriko.ai/v1", # default
timeout=60.0, # seconds, default: 60
max_retries=2, # default: 2
)
Retries
The SDK retries automatically when both conditions hold:
error.typeisrate_limit_errororapi_errorerror.codeis NOTbudget_exhausted,insufficient_quota, orinternal_error
Network failures (DNS, connection refused, timeout) retry under a separate rule and surface as APIConnectionError after the last attempt.
Retry uses exponential backoff (0.5s base, 1.5x multiplier, 30s cap) with jitter and respects Retry-After headers.
Error Handling
from auriko import Client
from auriko.errors import (
AurikoAPIError,
AuthenticationError,
BadRequestError,
RateLimitError,
)
client = Client()
try:
response = client.chat.completions.create(
model="gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
)
except AuthenticationError:
print("Invalid API key")
except BadRequestError as e:
print(f"Bad request ({e.code}): {e.message}")
except RateLimitError as e:
if e.code == "budget_exhausted":
print("Budget limit reached")
else:
print("Rate limited — retries exhausted")
except AurikoAPIError as e:
print(f"API error {e.status_code} ({e.code}): {e.message}")
Error classes
All errors inherit from AurikoAPIError. Dispatch is HTTP-status-driven; use .code for fine-grained branching.
| Error | HTTP status | Description |
|---|---|---|
BadRequestError |
400, 413 | Invalid request parameters |
AuthenticationError |
401 | Invalid or missing API key |
PermissionDeniedError |
403 | Feature disabled or insufficient permissions |
NotFoundError |
404 | Resource or model not found |
ConflictError |
409 | Idempotency-key conflict |
RateLimitError |
429 | Rate limit, quota, or budget exhausted |
InternalServerError |
500 | Internal gateway error |
APIStatusError |
502, 503, 504 | Upstream/gateway unavailable |
APIConnectionError |
— | No response received (network/DNS/timeout) |
Resource Management
Use the client as a context manager to ensure connections are properly closed:
with Client() as client:
response = client.chat.completions.create(...)
# Async
async with AsyncClient() as client:
response = await client.chat.completions.create(...)
Requirements
Python 3.10+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auriko-1.0.1.tar.gz.
File metadata
- Download URL: auriko-1.0.1.tar.gz
- Upload date:
- Size: 47.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ee64a8ac0da781d4735c2272b4103d433fd671ec6369638102d797d35239222
|
|
| MD5 |
3164730fa24ec7bccf8f53be534e40c7
|
|
| BLAKE2b-256 |
2b307e9255896188fcc96fd29bf9760e45a0960512eaaa2fac2e4be9472cf11d
|
File details
Details for the file auriko-1.0.1-py3-none-any.whl.
File metadata
- Download URL: auriko-1.0.1-py3-none-any.whl
- Upload date:
- Size: 58.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e55841a7fb32de4a700ecaccec30862fa7e672a5ab133b1f6d456f11569b38c
|
|
| MD5 |
e3bd73dd985a5454986f3ce531c6d873
|
|
| BLAKE2b-256 |
8f473ffc2e4fd755549e1fab5df4ec7585da62b50dc94f345bc4ca4f5c0b7a16
|