Authentication
Account session. Session/administrative writes are not executed in the public Playground.
Endpoint
curl --request POST 'https://api.oneaster.ai/core/v1/keys' \ --header 'Authorization: Bearer '"$ONEASTER_SESSION_TOKEN" \ --header 'Content-Type: application/json' \ --data "$REQUEST_BODY_JSON"
Parameters
—
Request JSON Schema
{
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"budget_micro": {
"anyOf": [
{
"type": "string",
"pattern": "^(?:[0-9]+|\\s*)$",
"description": "选填;省略、null 或空白不设置 Key 独立额度。填写正整数时不得超过钱包当前 balance_micro;额度单位为整数 micro。"
},
{
"type": "null"
}
]
},
"models": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"maxItems": 50,
"description": "选填;省略、null 或 [] 表示允许所有当前及未来模型,仍受账号分组、启用状态和预算限制。"
},
{
"type": "null"
}
]
},
"expires_at": {
"type": "string",
"format": "date-time"
}
},
"required": [
"name"
]
}
Responses
201
创建 Key;完整秘密只返回一次
{
"application/json": {
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"success": {
"const": true
},
"data": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"pattern": "^[0-9]+$"
},
"key": {
"type": "string"
},
"prefix": {
"type": "string"
},
"expires_at": {
"type": "string",
"format": "date-time"
},
"show_once": {
"const": true
},
"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"
}
},
"required": [
"id",
"key",
"prefix",
"expires_at",
"show_once",
"budget_micro",
"unlimited_budget"
]
}
},
"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"
]
}
}
}