Skip to main content
Arbytra 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 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)

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):
If no provider can meet the latency constraint, Arbytra 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:
Arbytra 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, Arbytra drops unsupported parameters and adds a warning to the response.
If no provider supports the parameters you sent, Arbytra 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, 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:
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.
Arbytra’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.

Read routing metadata

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