Provider Selection

Route requests to preferred providers with explicit policies

TheRouter.ai load balances across available providers by default. Add aprovider object in your request body to override routing behavior.

provider-fields.json
{
  "provider": {
    "order": ["openai", "anthropic"],
    "allow_fallbacks": true,
    "only": ["openai", "anthropic"],
    "ignore": ["google"]
  }
}

Provider references are brand names such as openai, anthropic, google or deepseek. A brand matches every route TheRouter.ai serves for that brand; a name that matches no route is ignored.

Ordering providers

Use provider.order to force a strict provider priority list. TheRouter.ai tries each provider in order, then continues to other providers whenallow_fallbacks is enabled.

TypeScript
const response = await fetch('https://api.therouter.ai/v1/chat/completions', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <THEROUTER_API_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'deepseek/deepseek-r1',
    messages: [{ role: 'user', content: 'Hello' }],
    provider: {
      order: ['deepseek'],
      allow_fallbacks: true,
    },
  }),
});

Allow and ignore lists

Restrict the provider pool with only and explicitly remove providers with ignore.

json
{
  "model": "deepseek/deepseek-r1",
  "provider": {
    "only": ["deepseek"],
    "allow_fallbacks": false
  },
  "messages": [{ "role": "user", "content": "Solve this optimization problem." }]
}
Fields that are accepted but not applied
TheRouter.ai applies order, only, ignore and allow_fallbacks. The fields sort, quantizations, data_collection, max_price and require_parameters are accepted for client compatibility but do not change routing today. Do not rely on them for price caps or data-handling policy.
Help & contact