AI Gateway

Replace an AI Gateway routing rule

Replace a routing rule's tiers. The slug is immutable; data capture is managed independently. This is a full replacement: omitted or null ordering resets the tier to configured, and omitted or null weights in a weighted_affinity tier reset to 1. Omitted or null reasoning_level clears a model destination's reasoning override. Replacing a rule repairs tiers reported with an ordering_issue.

put/api/v2/routing-rules

Request

Query parameters

slugstring required

Organization-unique routing rule slug.

Request body

Example request

{
  "data": {
    "attributes": {
      "tiers": [
        {
          "ordering": "configured",
          "targets": [
            {
              "id": 901,
              "model": "gpt-5.2-codex",
              "model_id": 101,
              "provider": "prod-us",
              "reasoning_level": "medium",
              "slug": "coding-fallback",
              "type": "model",
              "weight": 70
            }
          ]
        }
      ]
    },
    "id": "coding",
    "type": "routing-rules"
  }
}

Response

OK

Example response

{
  "data": {
    "attributes": {
      "created_at": "2026-08-24T12:00:00Z",
      "route_id": 123,
      "tiers": [
        {
          "ordering": "configured",
          "ordering_issue": "mixed",
          "targets": [
            {
              "id": 901,
              "model": "gpt-5.2-codex",
              "model_id": 101,
              "provider": "prod-us",
              "reasoning_level": "medium",
              "slug": "coding-fallback",
              "type": "model",
              "weight": 70
            }
          ]
        }
      ],
      "updated_at": "2026-08-24T12:00:00Z"
    },
    "id": "coding",
    "type": "routing-rules"
  }
}

Changes

Changes to this operation have not been checked yet.