API 参考
创建 Guardrail
创建可复用的模型、提供方和预算策略。
创建可复用的模型、提供方和预算策略。
端点
- 基础 URL
https://runapi.ai- API 版本
v1- 身份验证
Authorization: Bearer YOUR_MANAGEMENT_API_KEY- 授权
- 需要账户管理员的 Management API 密钥。
03
JSON 请求体请求
只能在列出的请求位置发送值。
JSON 请求体10 个字段
allowed_modelsarray | null
可选
Model allowlist.
allowed_providersarray | null
可选
Provider-name allowlist.
blocked_modelsarray | null
可选
Model blocklist, which takes precedence over the allowlist.
blocked_providersarray | null
可选
Provider-name blocklist.
credit_limit_centsinteger | null
可选
Total spending cap in USD cents.
credit_limit_reset_intervalstring | null
可选
Reset cadence for the total spending cap.
可选值:daily, weekly, monthly
descriptionstring
可选
Optional free-form description.
enabledboolean
可选
Whether the guardrail is enforced.
默认值:true
model_budgetsarray | null
可选
Per-model budget rules.
namestring
必填
Guardrail name unique within the account.
03
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
HTTP 401错误响应 (401)
JSON
{
"error": "Authentication required"
}
05
HTTP 403错误响应 (403)
JSON
{
"error": "Management API key required"
}
06
HTTP 403错误响应 (403)
JSON
{
"error": "Account admin required"
}
07
HTTP 400错误响应 (400)
JSON
{
"error": "page must be an integer"
}
08
HTTP 422错误响应 (422)
JSON
{
"errors": {
"base": [
"Validation failed"
]
}
}
09
cURL 示例
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"}]}'
10