管理员

GET /core/v1/admin/keys

管理员查询 Key 元数据

身份要求

管理员. 会话/管理写操作不在公共 Playground 执行。

接口

curl --request GET 'https://api.oneaster.ai/core/v1/admin/keys' \
  --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN"

参数

- page (query, 可选): {"type":"integer","minimum":1,"maximum":1000000,"default":1}

- size (query, 可选): {"type":"integer","minimum":1,"maximum":100,"default":20}

- search (query, 可选): {"type":"string","minLength":1,"maxLength":80} 名称字面子串或 Key 前缀;不支持秘密检索。

- model (query, 可选): {"type":"string","minLength":1,"maxLength":200}

- status (query, 可选): {"enum":["active","disabled","expired","revoked","exhausted"]}

- user_id (query, 可选): {"type":"string","pattern":"^[0-9]+$"}

响应

200

管理员查询 Key 元数据

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": true
        },
        "data": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "user_id": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                  },
                  "name": {
                    "type": "string"
                  },
                  "prefix": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "budget_micro": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^[0-9]+$",
                        "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "无限额时为 null;有限额时为累计总额度。unlimited_budget 明确表示模式,钱包限制始终适用。"
                  },
                  "unlimited_budget": {
                    "type": "boolean"
                  },
                  "spent_micro": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                  },
                  "reserved_micro": {
                    "type": "string",
                    "pattern": "^[0-9]+$",
                    "description": "整数账务单位;1 积分 = 10000 单位,1 USD = 100 积分。前端用 BigInt。"
                  },
                  "models": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "空数组表示所有当前及未来模型;非空数组表示精确允许列表。"
                  },
                  "revoked_at": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "config_version": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "created_at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "status": {
                    "enum": [
                      "active",
                      "disabled",
                      "expired",
                      "revoked",
                      "exhausted"
                    ]
                  }
                },
                "required": [
                  "id",
                  "user_id",
                  "name",
                  "prefix",
                  "enabled",
                  "expires_at",
                  "budget_micro",
                  "unlimited_budget",
                  "spent_micro",
                  "reserved_micro",
                  "models",
                  "revoked_at",
                  "config_version",
                  "created_at",
                  "status"
                ]
              }
            },
            "total": {
              "type": "string",
              "pattern": "^[0-9]+$"
            },
            "page": {
              "type": "integer",
              "minimum": 0
            },
            "size": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "items",
            "total",
            "page",
            "size"
          ]
        }
      },
      "required": [
        "success",
        "data"
      ]
    }
  }
}

default

错误代码见 core-api.md;供应商/数据库错误已隐藏。

{
  "application/json": {
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "success": {
          "const": false
        },
        "error": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "type": {
              "const": "oneaster_error"
            }
          },
          "required": [
            "code",
            "message",
            "type"
          ]
        },
        "data": {
          "type": "null"
        }
      },
      "required": [
        "success",
        "error",
        "data"
      ]
    }
  }
}