Skip to main content
POST
/
admin
/
model-mappings
Create a model route
curl --request POST \
  --url https://{organization_id}.platform.barndoor.ai/api/llm-gateway/admin/model-mappings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "provider_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "model_alias": "<string>",
  "upstream_model": "<string>",
  "enabled": true,
  "priority": 0,
  "retry_on_429_count": 0,
  "retry_on_429_max_wait_secs": 0,
  "bare_alias": true,
  "stream_idle_timeout_secs": 900,
  "max_concurrent_requests": 5000,
  "request_timeout_secs": 1800
}
'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "provider_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "model_alias": "gpt-4o-mini",
  "upstream_model": "gpt-4o-mini-2024-07-18",
  "enabled": true,
  "priority": 123,
  "retry_on_429_count": 5,
  "retry_on_429_max_wait_secs": 90,
  "bare_alias": true,
  "provider_name": "<string>",
  "stream_idle_timeout_secs": 900,
  "max_concurrent_requests": 5000,
  "request_timeout_secs": 1800,
  "budget_status": {
    "scope": "org",
    "target_id": "<string>",
    "budget_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "budget_name": "<string>",
    "period": "monthly",
    "usage": 123,
    "limit": 123
  }
}
A Model Route maps a client-facing alias to a (provider, upstream model) pair. Multiple routes can share the same model_alias — the gateway tries them in priority order (lowest first) and fails over to the next on upstream errors.

Two kinds of routes

  • 1:1 enablement (model_alias == upstream_model) — exposes the upstream model under its own name, addressable as <provider>/<upstream_model>. Defaults to bare_alias: false. Re-issuing this call for an existing enablement folds into the existing row, making it idempotent.
  • Custom alias (model_alias != upstream_model) — exposes the model under a friendly alias (e.g. team-coding-model). Defaults to bare_alias: true so callers can use the plain name in model. Requires an existing 1:1 enablement on the same (provider, upstream_model) pair.

Example: an alias with failover

The simplest production setup is one alias backed by a primary route plus one or more failover routes:
# Route 1: primary (priority 0)
curl -X POST https://app.barndoor.ai/api/llm-gateway/admin/model-mappings \
  -H "Authorization: Bearer $BARNDOOR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "provider_id": "<openai-provider-id>",
    "model_alias": "claude-opus-4-7",
    "upstream_model": "claude-opus-4-7",
    "priority": 0,
    "bare_alias": true
  }'

# Route 2: failover on Bedrock (priority 1)
curl -X POST https://app.barndoor.ai/api/llm-gateway/admin/model-mappings \
  -H "Authorization: Bearer $BARNDOOR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
    "provider_id": "<bedrock-provider-id>",
    "model_alias": "claude-opus-4-7",
    "upstream_model": "us.anthropic.claude-opus-4-7",
    "priority": 1,
    "bare_alias": true
  }'
For more on failover, retry policies, and bare aliases see Define Model Routes.

Authorizations

Authorization
string
header
required

JWT obtained through Barndoor's authentication flow. Pass the token verbatim in Authorization: Bearer <token>. Use the Barndoor SDK's loginInteractive() helper to obtain a token in scripts and notebooks.

Body

application/json
provider_id
string<uuid>
required
model_alias
string
required
upstream_model
string
required
enabled
boolean
default:true
priority
integer
default:0
retry_on_429_count
integer
default:0
Required range: 0 <= x <= 10
retry_on_429_max_wait_secs
integer
default:0
Required range: 0 <= x <= 180
bare_alias
boolean

Whether the route participates in bare-alias resolution. Defaults to true for custom aliases (where model_alias != upstream_model) and false for 1:1 enablement rows.

stream_idle_timeout_secs
integer | null
Required range: 1 <= x <= 1800
max_concurrent_requests
integer | null
Required range: 1 <= x <= 10000
request_timeout_secs
integer | null
Required range: 1 <= x <= 3600

Response

The newly created or updated route

A Model Route maps a client-facing alias to a specific provider and upstream model. One alias may have multiple routes; the gateway tries them in priority order and fails over on upstream errors.

id
string<uuid>
required
provider_id
string<uuid>
required
model_alias
string
required
Example:

"gpt-4o-mini"

upstream_model
string
required
Example:

"gpt-4o-mini-2024-07-18"

enabled
boolean
required
priority
integer
required

Lower numbers are tried first within the same alias

retry_on_429_count
integer
required

Same-route retries on upstream 429 before failing over

Required range: 0 <= x <= 10
retry_on_429_max_wait_secs
integer
required

Cap on honoring upstream Retry-After (0 = use small built-in default)

Required range: 0 <= x <= 180
bare_alias
boolean
required

When true the route participates in plain-alias resolution (e.g. model: "gpt-4o-mini"). When false it is only addressable as <provider>/<upstream-model>.

provider_name
string

Present on cross-provider listings

stream_idle_timeout_secs
integer | null
Required range: 1 <= x <= 1800
max_concurrent_requests
integer | null

Cap on in-flight requests per gateway pod against this route

Required range: 1 <= x <= 10000
request_timeout_secs
integer | null
Required range: 1 <= x <= 3600
budget_status
object

Present (and only present) when one of this route's targeted budgets with action_on_exhaust = block is currently exhausted. The runtime drops this route until the budget rolls over.