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 (
- Familiarity with Routing options
How routing works
When you send a request, Arbytra’s router:- Enumerates candidates — finds all providers offering the requested model(s)
- Filters by constraints — removes providers that violate your routing options (data policy, Bring Your Own Key (BYOK) requirement, performance constraints, excluded providers)
- Scores by strategy — ranks remaining candidates using your
optimizestrategy:cost: Cost-optimized, well-roundedcost-focus: Aggressively minimize cost (default)ttft: TTFT-optimized, well-roundedttft-focus: Aggressively minimize time to first tokentps: Throughput-optimized, well-roundedtps-focus: Aggressively maximize tokens per secondbalanced: All dimensions weighted evenly
- Selects and routes — selects from the ranked list, favoring higher-scored providers
- Falls back if needed — if the provider fails and
allow_fallbacksis true, retries with the next candidate (up tomax_fallback_attempts)
Use suffix shortcuts
Append a suffix to any model name for quick routing configuration:ft:gpt-4o:org:custom) pass through unchanged.
Route across models
Passgateway.models instead of model to route across multiple models (mutually exclusive with model, max 10):
Set quality constraints
Filter providers by performance requirements. Pass constraint ceilings undergateway.routing:
max_ttft_ms, min_throughput_tps, max_cost_per_1m) evaluate against median (p50) metrics. To rank providers by worst-case (p95) TTFT or throughput for scoring, set ttft_percentile or throughput_percentile — see Choose metric percentile.
Filter by parameter support
Not all providers support every optional parameter. By default, Arbytra drops unsupported parameters and adds a warning to the response. Setrequire_parameters to true to only route to providers that accept the optional parameters you sent:
require_parameters to true, Arbytra checks that your provider supports each one you sent: temperature, top_p, seed, logit_bias, logprobs, top_logprobs, n, presence_penalty, frequency_penalty, user, parallel_tool_calls, web_search_options, verbosity, prompt_cache_key, safety_identifier.
require_parameters composes with other constraints. A provider must pass all filters to be eligible. You can check which parameters each provider supports via the model directory endpoint, where each provider entry includes accepted_params and supported_parameters fields.
Set custom weights
You can override preset strategies with custom weights across three dimensions.
Pass
routing.weights with your desired dimensions:
- The server accepts any non-negative numbers and normalizes them proportionally.
- Omitted dimensions default to 0.
- At least one dimension must be greater than 0.
weightsoverrides theoptimizepreset, and the response metadata containsrouting_strategy: "custom".- To score using worst-case metrics, set
ttft_percentileand/orthroughput_percentileto"p95". See Choose metric percentile.
Choose metric percentile
By default, Arbytra scores providers using median (p50) metrics. You can switch to 95th-percentile (worst-case) independently for TTFT and throughput:
Both scoring fields accept
"p50" (median) or "p95" (worst-case). They work with presets and custom weights — no weights required.
Example — rank providers by worst-case (p95) TTFT instead of median:
Data policy
Control how providers handle your data: Arbytra doesn’t store prompts or responses. Setdata_policy: "zdr" to route only to providers that satisfy zero data retention.
The hierarchy is
zdr > no_training > none. When a per-request policy intersects with an account-level policy, the most restrictive one wins.
Opt in to premium tiers
Premium-tier offerings are excluded from routing by default. Settier to opt in:
Provider alias normalization
Provider names inproviders and exclude_providers are case-insensitive and support aliases:
Unrecognized names pass through as-is (lowercased).
Configure fallbacks
By default, Arbytra retries with alternative providers on 429 (rate limit), 5xx (server error), and timeout responses.
You can configure per-attempt timeouts with
timeout_ms. To set a hard wall-clock cap across all fallback attempts, use deadline_ms. Non-streaming requests have an 18-minute default deadline; streaming requests have no deadline (opt-in only). If the deadline is exceeded, the request fails with a timeout error.