Skip to main content
Fine-tune routing with suffix shortcuts, multi-model requests, quality constraints, and data policies. For basic routing, see Routing options.

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)
  • Familiarity with Routing options

How routing works

When you send a request, Arbytra’s router:
  1. Enumerates candidates — finds all providers offering the requested model(s)
  2. Filters by constraints — removes providers that violate your routing options (data policy, Bring Your Own Key (BYOK) requirement, performance constraints, excluded providers)
  3. Scores by strategy — ranks remaining candidates using your optimize strategy:
    • cost: Cost-optimized, well-rounded
    • cost-focus: Aggressively minimize cost (default)
    • ttft: TTFT-optimized, well-rounded
    • ttft-focus: Aggressively minimize time to first token
    • tps: Throughput-optimized, well-rounded
    • tps-focus: Aggressively maximize tokens per second
    • balanced: All dimensions weighted evenly
  4. Selects and routes — selects from the ranked list, favoring higher-scored providers
  5. Falls back if needed — if the provider fails and allow_fallbacks is true, retries with the next candidate (up to max_fallback_attempts)
See Python SDK or TypeScript SDK for routing code examples.

Use suffix shortcuts

Append a suffix to any model name for quick routing configuration:
Suffixes work with any HTTP client:
The router parses suffixes only when the model ID contains exactly one colon. Fine-tuned models with multiple colons (for example, ft:gpt-4o:org:custom) pass through unchanged.

Route across models

Pass gateway.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 under gateway.routing:
Constraint ceilings (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. Set require_parameters to true to only route to providers that accept the optional parameters you sent:
The following parameters have per-provider support. When you set 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.
  • weights overrides the optimize preset, and the response metadata contains routing_strategy: "custom".
  • To score using worst-case metrics, set ttft_percentile and/or throughput_percentile to "p95". See Choose metric percentile.
Providers approaching their rate limits are automatically deprioritized.

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. Set data_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. Set tier to opt in:
Arbytra’s “priority” tier refers to Anthropic Fast Mode, not Anthropic’s separate Priority Tier (committed capacity SLA). See Routing options for details.

Provider alias normalization

Provider names in providers 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.