Provider Routing
Choose, order and exclude the providers that serve a model, or let OhMyGPT pick.
Many models are served by more than one provider. zhipu/glm-5.3-flash, for example:
curl -s https://api.ohmygpt.com/v1/models/zhipu/glm-5.3-flash | jq -r '.providers[].provider'chatglm
tencentYou don't have to choose: by default OhMyGPT picks a provider for each request by weighing price against speed and reliability, and tries to keep a conversation with the provider that already holds its prompt cache. If that provider fails before answering, the request goes to the next one. When you do want a say, for example the cheapest provider or a fixed fallback order, add a top-level provider object on /v1/chat/completions, /v1/responses or /v1/messages:
curl https://api.ohmygpt.com/v1/chat/completions \
-H "Authorization: Bearer $OHMYGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zhipu/glm-5.3-flash",
"messages": [{"role": "user", "content": "Hi"}],
"provider": {"order": ["chatglm"]}
}'Fields
| Field | Type | Effect |
|---|---|---|
order | string[] | Try these providers first, in this order. The model's other providers stay available as fallbacks. |
only | string[] | Use only these providers. |
ignore | string[] | Never use these providers. |
allow_fallbacks | boolean | Defaults to true. With false, only the providers in order are used; without order, only the first-ranked provider is used. |
sort | string or object | Prefer providers by price (lowest cost for this request), latency (fastest time to first token) or throughput (most tokens per second). The object form {"by": "price"} works too. |
max_price | object | Skip providers priced above these limits, in USD: prompt and completion per million tokens, image per image, request per request. See Cap the price. |
zdr | boolean | With true, use only providers that keep no prompts or outputs after processing. See Data retention and training. |
data_collection | string | allow (the default) or deny. With deny, use only providers that don't train on API data. |
Use the slugs from the model's providers[].provider list; case doesn't matter. OpenRouter's provider slugs work too: amazon-bedrock, google-vertex, google-ai-studio, claude-on-aws, moonshotai, z-ai and seed mean bedrock, vertex, google, anthropic_aws, moonshot, chatglm and bytedance. Keep at least one of the model's providers in only, and don't ignore all of them: a request that leaves no provider is rejected with 400 invalid_parameter, naming provider.only or provider.ignore (or provider.order when allow_fallbacks is false). With both order and sort, the providers in order come first and sort ranks the rest.
To see which provider served a request, look it up by its X-Request-ID. The receipt's model.provider field names it.
Cap the price
max_price skips every provider whose price for your account is above a limit; a provider priced exactly at the limit is used. The price compared is the one for this request's service tier and the current time of day. On models whose price rises with input length, the tier comes from an estimate of the request's input tokens, capped at the model's input limit, and the requested output limit, made before the request is sent; the tier you are finally billed at follows the actual token counts. Limits are numbers or numeric strings. Combine max_price with sort to ask for, say, the fastest provider that costs at most $1 per million input tokens:
curl https://api.ohmygpt.com/v1/chat/completions \
-H "Authorization: Bearer $OHMYGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zhipu/glm-5.3-flash",
"messages": [{"role": "user", "content": "Hi"}],
"provider": {"sort": "throughput", "max_price": {"prompt": 1, "completion": "4"}}
}'Models on /v1/chat/completions and /v1/responses have no per-request price, so request never skips a provider, and image applies only to models priced per image. When every provider is above the limits, the request is rejected before it reaches a model:
{
"error": {
"param": "provider.max_price",
"code": "invalid_parameter",
"message": "No provider of the model `zhipu/glm-5.3-flash` is priced within `provider.max_price`. Raise or remove the limit; each provider's price is listed in `GET /v1/models`.",
"type": "invalid_request_error"
}
}Data retention and training
zdr and data_collection go by each provider's own published policy for API traffic: what the provider does by default, without an enterprise agreement or an opt-in on its account. A provider that offers zero retention only after approval, or whose policy doesn't say clearly, doesn't qualify. zdr: true uses only providers that keep nothing after processing a request; prompt caching held in memory doesn't count as keeping data. data_collection: "deny" uses only providers that don't train on API inputs or outputs.
Some providers train on API data only if the account opts in to data sharing, or, for the Gemini API, only on unpaid use. OhMyGPT's own provider accounts never opt in where opting out is possible, so requests on OhMyGPT's keys get the provider's default.
Each provider's policy for a model is listed under data_policy in GET /v1/models:
curl -s https://api.ohmygpt.com/v1/models/openai/gpt-oss-120b | jq '.providers[] | {provider, data_policy}'{
"provider": "cerebras",
"data_policy": {
"training": false,
"training_policy_url": "https://www.cerebras.ai/terms-of-service",
"retention": "none",
"retention_policy_url": "https://www.cerebras.ai/privacy-policy",
"moderation": "developer",
"zdr": true
}
}retention_policy_url and training_policy_url are the provider's pages that state each policy. training is left out when the provider's policy doesn't say. Retention can depend on the model and on the endpoint: zdr is true only when the provider keeps nothing on every endpoint it serves the model on. When its endpoints differ, retention shows the one that keeps data and protocols lists each endpoint by its protocol ID. A zdr request uses the provider on the endpoints whose zdr is true. Fireworks, for example, stores Responses API conversations for 30 days by default, so a zdr request on /v1/responses skips it while one on /v1/chat/completions can use it:
"protocols": [
{"id": "openai-completions", "retention": "none", "zdr": true},
{"id": "openai-responses", "retention": "30d", "zdr": false},
{"id": "anthropic-messages", "retention": "none", "zdr": true}
]Your own provider keys are judged by the same published default, but your account's settings with the provider decide what actually happens to your data. A free-tier Gemini API key, for example, is trained on even when you send data_collection: "deny".
zdr covers the providers, not OhMyGPT itself. /v1/responses stores each successful response for 30 days so that previous_response_id works; send "store": false to skip that. When a request fails or a stream is cut off, OhMyGPT keeps its request body for 3 months to investigate the failure.
When no provider of the model qualifies, the request is rejected before it reaches a model, naming the field:
{
"error": {
"param": "provider.zdr",
"code": "invalid_parameter",
"message": "No provider of the model `openai/gpt-4o` has a published data policy that meets `provider.zdr`. Remove the requirement or choose another model; each provider's policy is listed under `data_policy` in `GET /v1/models`.",
"type": "invalid_request_error"
}
}If a provider that qualifies was left out by your own choice, such as provider.only, provider.ignore or a provider prefix in the model ID, the error names that choice instead.
From the OpenAI SDKs
Pass provider as an extra body field:
completion = client.chat.completions.create(
model="zhipu/glm-5.3-flash",
messages=[{"role": "user", "content": "Hi"}],
extra_body={"provider": {"order": ["chatglm"]}},
)Pin a provider in the model ID
Prefix the model ID with a provider slug: tencent:zhipu/glm-5.3-flash sends the request to Tencent only, like "only": ["tencent"]. The prefix works on every endpoint. On the Gemini endpoint it is the way to choose a provider; leave the provider object out there.
Models routed by OhMyGPT
For models with managed_routing: true in the model list, OhMyGPT picks the provider for you. Call them by their plain ID, without a prefix or a provider object; if you send one, its choices are ignored. The charge on each response reflects the provider that served it.
Migrating from OpenRouter
| OpenRouter | OhMyGPT |
|---|---|
model: "x:floor" | "provider": {"sort": "price"} |
model: "x:nitro" | "provider": {"sort": "throughput"} |
"provider": {"order": [...]} | Same field, with OpenRouter's slugs |
"provider": {"only": [...]}, "ignore": [...] | Same fields, with OpenRouter's slugs |
"provider": {"allow_fallbacks": false} | Same field |
"provider": {"sort": {"by": "price"}} | Same field |
"provider": {"max_price": {...}} | Same field; audio is not supported |
"provider": {"zdr": true}, "data_collection": "deny" | Same fields, judged by each provider's published policy |
models: [...] fallback list | Pick one model; fallback across its providers is automatic |
Send model IDs exactly as listed, with no suffix. Leave out other provider fields such as quantizations and region; requests that set them are rejected with 400 unsupported_parameter.
An invalid value names the field to fix:
{
"error": {
"param": "provider.sort",
"code": "invalid_parameter",
"message": "Invalid `provider.sort`: must be one of `price`, `latency`, `throughput`, not `speed`.",
"type": "invalid_request_error"
}
}Still stuck? Live chat · [email protected] · Telegram group