---
title: "Provider routing"
description: "Filter and order the hosts that serve a request."
---

# Provider routing

The `provider` object chooses which hosts can serve a request and in what order. A provider here means a host, named as in `X-PG-Host` (for example `DeepInfra`) or by its tag.
Requests without it use the model's default order, with the pinned host first.

| Field | Type | Effect |
|---|---|---|
| `order` | string[] | Try these hosts first, in this order, then the other eligible hosts. |
| `only` | string[] | Allow only these hosts. |
| `ignore` | string[] | Never use these hosts. |
| `sort` | string, or object with `by` | Order by `price`, `throughput` or `latency`. Throughput and latency use each host's configured figures. |
| `allow_fallbacks` | boolean | `false` tries only the hosts named in `order`, or only the first host without `order`. |
| `data_collection` | string | `deny` keeps only hosts marked as never keeping data. |
| `zdr` | boolean | `true` keeps only hosts marked zero data retention. |
| `quantizations` | string[] | Keep hosts running these quantizations; `unknown` matches a host that states none. |
| `max_price` | object | Highest `prompt` and `completion` price, in USD per 1M tokens, at our price. Each value is a number or a decimal string, such as `1` or `"1"`. `image`, `audio` and `request` are accepted and have no effect. |
| `require_parameters` | boolean | Accepted; no effect yet. |
| `preferred_max_latency` | number or object | Accepted; no effect yet. |
| `preferred_min_throughput` | number or object | Accepted; no effect yet. |
| `enforce_distillable_text` | boolean | Accepted; no effect yet. |
| `options` | object | Accepted; no effect yet. |

```sh
curl https://api.plaingateway.com/api/v1/chat/completions \
  -H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek/deepseek-v4-flash", "messages": [{"role": "user", "content": "Hello"}], "provider": {"order": ["Azure"], "max_price": {"prompt": 1, "completion": 4}}}'
```

These are OpenRouter's fields, with OpenRouter's types. A field OpenRouter does not have, in `provider` or `max_price`, a value of the wrong type, a bad `sort` value, or a `data_collection` other than `allow` or `deny` returns 400.

## Account settings

The rules on a workspace's Routing page apply to every request from that workspace's keys, and the Privacy settings to every key of your account. See [Workspaces](../billing/workspaces.md). Changes reach the gateway within about 10 seconds.

| Setting | Page | Effect |
|---|---|---|
| **Default provider choice** | [/settings/preferences](https://plaingateway.com/settings/preferences) | The same as `provider.sort`. Pinned means no sort. A request that sets `provider.sort` overrides it. |
| **Allow fallbacks** off | [/settings/preferences](https://plaingateway.com/settings/preferences) | The same as `provider.allow_fallbacks: false`: one host per model, and that host's error is returned. A request that sets `provider.allow_fallbacks` overrides it. |
| **Allowed providers** | [/settings/preferences](https://plaingateway.com/settings/preferences) | Only these hosts serve. A request's `provider.only` can narrow the list but never widen it, so a request that names only other hosts gets 404. |
| **Ignored providers** | [/settings/preferences](https://plaingateway.com/settings/preferences) | These hosts never serve. They are added to the request's `provider.ignore`, and a request cannot remove them. |
| **Max price** | [/settings/preferences](https://plaingateway.com/settings/preferences) | The same as `provider.max_price.completion`, in USD per 1M output tokens. A request that sets `provider.max_price.completion` overrides it, and a request that sets it to `null` has no max price. Like `max_price`, it never drops your own provider keys. |
| **Zero data retention only** on | [/settings/privacy](https://plaingateway.com/settings/privacy) | The same as `provider.zdr: true`, and a request cannot turn it off. See [Zero data retention](../features/zero-data-retention.md). |

## When no host is left

Filters run in this order: API shape, `only`, the allowed providers setting, `ignore` (with the ignored providers setting), `quantizations`, `data_collection`, `zdr`, `max_price`, and settings rules (a host that routes on its own, such as an OpenRouter-compatible gateway, never serves while any Routing or Privacy setting applies). The first filter that leaves no host ends routing with 404:

```json
{
  "error": {
    "message": "No endpoints found matching your provider.only list",
    "code": 404,
    "metadata": {
      "routing_funnel": [{"step": "Initial Endpoints", "endpoint_count": 2}, {"step": "Filter by API Shape", "endpoint_count": 2}],
      "failed_routing_step": "Filter by Only"
    }
  }
}
```

`routing_funnel` lists how many hosts were left after each step that ran. `failed_routing_step` names the step that left none.
