Skip to main content
A routing policy is a saved model chain: which models to try, how to pick among them, and the provider routing preferences every attempt follows. Save it once under a name and every request can use it as model: "policy/{name}", so an app that only lets you configure a model string, such as a coding agent or a chat UI, gets your fallbacks and provider preferences without any change to the request. Bind the policy to an API key and even the model string stays as it is. Policies are managed through the Management API. A management key manages the organization’s policies, shared by every member and key of the organization; your own API key manages your personal ones.

Creating a policy

PUT /v3/manage/routing-policies/{name}/ creates the policy, or replaces it whole when it exists. This one tries GPT on Azure, retries it once, then moves to OpenAI, then to Kimi on whichever provider is cheapest, and finally to DeepSeek:
cURL
Response (201 Created)
Every target is checked against the catalog when you save: a model that does not exist, a weight on a strategy other than load_balance, or any other broken rule is a 422 whose error.fields names each offending field by path (targets.0.weight), so nothing half-valid is ever stored. A name is 2 to 63 lowercase letters, digits or dashes, starting with a letter or digit. An organization or a user holds at most 100 policies.

Calling a policy

Send the name as the model, on any of the three chat dialects (/v3/chat/completions, /v3/responses and /v3/v1/messages), streaming or not:
cURL
The policy’s chain replaces the model: the request runs down it until a target answers, exactly as if you had written that chain in model and fallbacks yourself. The response is the ordinary one for the endpoint; with the x-edenai-metadata header it also says what the policy did.
  • Your own fallbacks are kept. Models you list in the request are tried after the policy’s targets and fallbacks.
  • A suffix on the name sets the sort for this call. policy/prod-chat:latency is the same as sending routing.sort: "latency", and counts as sort for the policy’s lock. See Choosing an objective.
  • A region tag pins every target. policy/prod-chat@eu runs each target in Europe; a target not served there is dropped for the call with the reason region. Write both as policy/prod-chat@eu:latency. See Pinning a region.
  • Names are matched regardless of case, like a provider prefix. The name must be yours or your organization’s: a personal policy with the same name as an organization one wins for your requests.
The name is only accepted where a model chain is: the chat dialects above. To embeddings, images, audio and the other endpoints it is an unknown model.

The policy object

A target: routing, in defaults and on a target, is the request’s routing object: sort, order, allowed_providers, ignored_providers, max_price, allow_fallbacks, sticky and zero_data_retention. quality_cost is not accepted. A field set to null is unset: it then comes from the request or the platform default.

Strategies

Each strategy turns the targets into an ordered chain for the request, which then runs like a fallback list: the first target that answers serves. A target named without a provider is still routed across its providers by the merged routing. Whatever the strategy, a request makes at most 8 attempts, retries included: entries beyond the limit are dropped for the call with the reason chain_limit.

Routing preferences and precedence

Each routing field is settled independently: the request wins, then the target, then the policy’s defaults, then the platform default. A policy therefore sets preferences a request can still refine, unless the policy locks them.
With this policy a request may send routing.sort: "latency" and get it, but a request that sends ignored_providers is refused:
A :sort suffix on the model counts as sort, and an @region tag as region. A merge that names a provider in both allowed_providers and ignored_providers, one from the policy and one from the request, is also a 400.

Credentials

By default a target runs on your own provider key when you have stored one for its provider, and on Eden AI’s otherwise. credentials fixes that per target, or for all of them in defaults: own and eden need a concrete provider/model target, since a routable name fans out across providers, and a policy uses one mode per provider.

Binding a policy to an API key

A key’s default_policy applies a policy to every chat call made with the key, on the three dialects above; the other endpoints ignore it. Set it when you create the key or later:
cURL
What the bound policy does depends on the model the request names: A routing-only policy, one without targets, exists for the second row: it cannot be called by name. Send null to unbind. Deleting a policy unbinds every key that used it, and a key bound to a disabled policy behaves as unbound. Through the Management API only the organization’s policies can be bound.

Organization and personal policies

A personal policy may share a name with an organization one, and then wins on your requests. ?scope=user or ?scope=organization limits a list or a read to one scope; a write always goes to the credential’s own scope, and naming the other one is a 403. Each PUT increments version, returned as version and etag and in the ETag header. To replace only the version you read, send it back as If-Match: "2": when the policy changed meanwhile the reply is a 412 carrying the current version. If-Match: "0" creates the policy only when nothing is stored yet.
cURL
The list is paginated like the other management endpoints (results, limit, offset, total_count, next, previous) and ordered by name, a personal policy before the organization’s one of the same name. GET or DELETE on a name you do not hold is a 404.

Seeing what the policy did

Send x-edenai-metadata: enabled and the request metadata block carries "strategy": "policy" and a policy object:
A dropped target is skipped, and the chain goes on with the next target, then the policy’s fallbacks, then your own. Only when nothing at all is left does the request fail rather than run elsewhere: 403 when every drop is the guardrail’s, 451 when every drop is the region’s, 400 otherwise, naming the policy and the reasons. Eden AI also records the policy’s name and version on every request it serves, so support can trace a call back to the policy version that routed it.

Zero data retention

A policy that sets routing.zero_data_retention: true, in defaults or on any target, holds the whole request to it: every target and fallback, the request’s own fallbacks included, is served only by providers that keep no prompts or outputs, and Eden AI saves neither the request nor the response. A key that lends a policy’s routing only holds the request when defaults ask for it. See Compliance Policies.

Finding your policies

Send your API key with the grouped model listing and it adds one entry per policy you can call:
cURL
The entry carries the name only: which target serves a call is decided per request, so there is no price, context window or region to summarise. Only enabled policies with targets are listed. The default listing (view=endpoints) and any zero_data_retention filter leave policies out, as does every other model listing.

Errors

Next Steps

Provider Routing

The routing object a policy stores

Fallback

How a chain of models is tried

Custom API Keys

Bind a policy when you create a key

Management API

The keys that manage policies