Auriko selects a provider for each request based on your routing configuration. Pass routing options in the gateway.routing object to control strategy, constraints, and provider filtering.
Prerequisites
- An Auriko API key
- Python 3.10+ with the OpenAI SDK (
pip install openai) or the auriko SDK (pip install auriko)
- OR Node.js 18+ with the OpenAI SDK (
npm install openai) or @auriko/sdk (npm install @auriko/sdk)
Compare strategies
Auriko supports seven optimization strategies:
| Strategy | Description | Best For |
|---|
cost | Cost-optimized, well-rounded | Cost-conscious production, budget-sensitive apps |
cost-focus (default) | Aggressively minimize cost | Maximum cost savings, no latency requirements |
ttft | TTFT-optimized, well-rounded | Streaming UX, interactive apps |
ttft-focus | Aggressively minimize time to first token | Real-time applications, chatbots |
tps | Throughput-optimized, well-rounded | High-volume processing |
tps-focus | Aggressively maximize tokens per second | Maximum throughput, pipeline processing |
balanced | All dimensions weighted evenly | General-purpose, mixed workloads |
Base vs. focus
Base strategies (cost, ttft, tps) optimize for the named dimension while still considering other quality factors.
Focus strategies (cost-focus, ttft-focus, tps-focus) optimize almost entirely for the named dimension. Other factors have minimal influence.
| Type | Behavior | Use when |
|---|
Base (cost, ttft, tps) | Favors the named dimension, well-rounded | Production workloads needing reliable performance |
Focus (cost-focus, ttft-focus, tps-focus) | Aggressively optimizes the named dimension | Batch processing, real-time streaming UI, high-throughput pipelines |
For custom weight configurations beyond the preset strategies, see Set custom weights.
Optimize for cost
Auriko computes the expected cost of each request at every available provider and routes to the cheapest one. The cost model accounts for caching and pricing tiers.
See Cost optimization for configuration, code examples, and the full cost model.
Optimize for latency
Route requests to low-latency providers:
Set latency constraints
Set maximum time-to-first-token (TTFT):
If no provider can meet the latency constraint, Auriko returns a 400 error.
max_ttft_ms evaluates against median (p50) metrics by default. To constrain on worst-case latency, set ttft_percentile to "p95". See Choose metric percentile.
Set cost ceilings
Exclude providers that exceed a per-1M-token budget:
Auriko calculates cost as the average of input and output price per 1M tokens. Providers exceeding this ceiling are excluded from routing.
For fine-grained constraints, see Advanced routing and Cost optimization.
Require supported parameters
Set require_parameters to true to only route to providers that accept all optional parameters you sent (like seed, logit_bias, or top_logprobs). Without this flag, Auriko drops unsupported parameters and adds a warning to the response.
If no provider supports the parameters you sent, Auriko returns a 400 error with code required_params_not_supported. See Filter by parameter support for the full list of parameters this applies to.
Prefer or exclude providers
Prefer or exclude specific providers:
You can hint at a preferred provider without restricting the candidate pool:
prefer is a soft hint. If the preferred provider is available, Auriko routes to it. If not, routing proceeds normally. Unlike providers, a prefer miss doesn’t fail the request.
Restrict key source
Force requests to use only BYOK (bring-your-own-key) or only platform-managed keys:
Both are booleans, default false. Setting both to true returns a 400 error. They’re mutually exclusive.
When no key of the requested type is available, the request fails with no fallback. See Bring Your Own Key for BYOK setup.
Opt in to premium tiers
Premium-tier offerings are excluded from routing by default to prevent accidental cost escalation. Set tier to opt in.
| Value | Effect |
|---|
"priority" | Includes Anthropic Fast Mode offerings (2.5x speed, 6x cost) |
| omitted (default) | Excludes premium-tier offerings |
Auriko’s “priority” tier refers to Anthropic Fast Mode, not Anthropic’s separate Priority Tier (committed capacity SLA).
Without tier, requests to models available only under a premium tier return tier_opt_in_required.
Every response carries routing information:
For routing metadata with the OpenAI SDK, see OpenAI Compatibility.
For the complete field reference including fallback chain, warnings, and all optional fields, see Response Extensions.
Combine routing options