gateway.routing object to control strategy, constraints, and provider filtering.
Prerequisites
- An Arbytra API key
- Python 3.10+ with the OpenAI SDK (
pip install openai) or the arbytra SDK (pip install arbytra)- OR Node.js 18+ with the OpenAI SDK (
npm install openai) or@arbytra/sdk(npm install @arbytra/sdk)
- OR Node.js 18+ with the OpenAI SDK (
Compare strategies
Arbytra supports seven optimization strategies: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.
For custom weight configurations beyond the preset strategies, see Set custom weights.
Optimize for cost
Arbytra 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):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:Require supported parameters
Setrequire_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, Arbytra drops unsupported parameters and adds a warning to the response.
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:prefer is a soft hint. If the preferred provider is available, Arbytra 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: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. Settier to opt in.
Arbytra’s “priority” tier refers to Anthropic Fast Mode, not Anthropic’s separate Priority Tier (committed capacity SLA).
tier, requests to models available only under a premium tier return tier_opt_in_required.