Skip to content
API Reference
API Reference

Create a guardrail

Create a reusable model, provider, and budget policy.

Create a reusable model, provider, and budget policy.

Endpoint

POST /api/v1/guardrails
Base URL
https://runapi.ai
API version
v1
Authentication
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
Authorization
Requires an account-admin Management API key.
02

Request

JSON body

Send values only in the listed request location.

JSON body10 fields
allowed_modelsarray | null
Optional

Model allowlist.

allowed_providersarray | null
Optional

Provider-name allowlist.

blocked_modelsarray | null
Optional

Model blocklist, which takes precedence over the allowlist.

blocked_providersarray | null
Optional

Provider-name blocklist.

credit_limit_centsinteger | null
Optional

Total spending cap in USD cents.

credit_limit_reset_intervalstring | null
Optional

Reset cadence for the total spending cap.

Allowed values: daily, weekly, monthly
descriptionstring
Optional

Optional free-form description.

enabledboolean
Optional

Whether the guardrail is enforced.

Default: true
model_budgetsarray | null
Optional

Per-model budget rules.

namestring
Required

Guardrail name unique within the account.

03

Success response

HTTP 201

POST /api/v1/guardrails

JSON
{
  "allowed_models": [
    "gpt-5.4"
  ],
  "allowed_providers": [],
  "assignment_count": 1,
  "blocked_models": [],
  "blocked_providers": [],
  "created_at": "2026-07-27T10:00:00.000Z",
  "credit_limit_cents": 50000,
  "credit_limit_reset_interval": "monthly",
  "description": "Production policy",
  "enabled": true,
  "id": "guardrail_123",
  "model_budgets": [
    {
      "credit_limit_cents": 10000,
      "credit_limit_reset_interval": "monthly",
      "match_mode": "include",
      "models": [
        "gpt-5.4"
      ]
    }
  ],
  "name": "Production budget"
}
04

Error response (401)

HTTP 401
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Authentication required"
}
05

Error response (403)

HTTP 403
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Management API key required"
}
06

Error response (403)

HTTP 403
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable error message.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Account admin required"
}
07

Error response (400)

HTTP 400
Response schema
JSON
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Human-readable error message.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Human-readable validation summary.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}

Response example

JSON
{
  "error": "page must be an integer"
}
08

Error response (422)

HTTP 422
Response schema
JSON
{
  "properties": {
    "error": {
      "description": "Human-readable validation summary.",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "Validation messages keyed by public request field, with an array of human-readable strings for each field.",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}

Response example

JSON
{
  "error": "Validation failed",
  "errors": {
    "base": [
      "Validation failed"
    ]
  }
}
09

cURL example

CURL
curl -X POST https://runapi.ai/api/v1/guardrails \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Production budget","description":"Production policy","enabled":true,"credit_limit_cents":50000,"credit_limit_reset_interval":"monthly","allowed_models":["gpt-5.4"],"model_budgets":[{"match_mode":"include","models":["gpt-5.4"],"credit_limit_cents":10000,"credit_limit_reset_interval":"monthly"}]}'