---
title: 获取 Guardrail
url: https://runapi.ai/zh-CN/docs/api/management/guardrails/retrieve.md
canonical: https://runapi.ai/zh-CN/docs/api/management/guardrails/retrieve
locale: zh-CN
---

# 获取 Guardrail

通过前缀 ID 获取一个激活的 Guardrail。

## 端点

GET /api/v1/guardrails/:id

基础 URL: https://runapi.ai

API 版本: v1

身份验证: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


授权: 需要账户管理员的 Management API 密钥。

## 请求

只能在列出的请求位置发送值。

### 路径参数

```json
{
  "id": {
    "description": "Guardrail prefix ID, for example guardrail_abc123.",
    "required": true,
    "type": "string"
  }
}
```

## 成功响应

HTTP 200 - GET /api/v1/guardrails/:id

```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"
}
```

## 错误响应 (401)

HTTP 401

```json
{
  "error": "Authentication required"
}
```

## 错误响应 (403)

HTTP 403

```json
{
  "error": "Management API key required"
}
```

## 错误响应 (403)

HTTP 403

```json
{
  "error": "Account admin required"
}
```

## 错误响应 (404)

HTTP 404

```json
{
  "error": "Resource not found"
}
```

## cURL 示例



### curl

```curl
curl -X GET https://runapi.ai/api/v1/guardrails/guardrail_123 \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY'
```

## 相关参考

- [Guardrails](/docs/api/management/guardrails)
- [Guardrail 对象](/docs/api/management/guardrails/object)
