通过 OpenAPI 管理租户推理 API Key(sk- 前缀)。Base URL:https://www.51kik.com,鉴权见 访问令牌。
接口一览
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /openapi/api-keys | 分页列表 |
| POST | /openapi/api-keys | 创建(明文 apiKey 仅返回一次) |
| GET | /openapi/api-keys/:id | 单条详情 |
| PATCH | /openapi/api-keys/:id | 更新 |
| DELETE | /openapi/api-keys/:id | 删除 |
| GET | /openapi/api-keys/:id/plaintext | 获取完整密钥明文 |
Key 对象字段
列表 items[]、GET 详情、PATCH 成功响应均返回下列 Key 对象(不含明文 apiKey):
| 字段 | 类型 | 说明 |
|---|---|---|
id | number | 密钥 ID |
description | string | 备注 |
keyPreview | string | 脱敏预览(如 sk-xxxx…yyyy) |
createTime | string | 创建时间(UTC ISO 8601) |
enabled | boolean | 是否启用 |
creditLimit | number | null | 费用额度上限(credits);null 表示不限 |
creditResetInterval | string | 额度重置周期:none / daily / weekly / monthly |
expiresAt | string | null | 过期时间(UTC ISO 8601);never 创建时为 null |
usedQuotaCostCredit | number | null | 当前计费窗口内已消耗 credits;未配置 creditLimit 时为 null |
totalUsedCostCredit | number | 历史上累计消耗 credits;无用量时为 0 |
whitelistModelCount | number | 模型白名单条目数;0 表示不限制模型 |
whitelistIpCount | number | IP 白名单条目数;0 表示不限制来源 IPv4 |
lastUsedAt | string | null | 最近一次调用时间(UTC ISO 8601);从未调用时为 null |
tags | string[] | 标签(小写存库,字典序) |
employeeNo | string | null | 绑定的组织成员工号 |
orgUserDisplayName | string | null | 绑定的组织成员显示名 |
列表
curl -sS "https://www.51kik.com/openapi/api-keys?page=1&page_size=20" \
-H "X-Access-Token: $ACCESS_TOKEN"
Query 参数:
| 参数 | 类型 | 说明 |
|---|---|---|
page | number | 页码,默认 1 |
page_size | number | 每页条数,默认 20,最大 100 |
q | string | 按描述模糊搜索 |
tag | string | 按标签精确过滤 |
employee_no | string | 按组织成员工号过滤;工号不存在时返回空列表 |
响应 data 示例:
{
"items": [
{
"id": 1,
"description": "prod",
"keyPreview": "sk-xxxx…yyyy",
"createTime": "2026-06-01T08:00:00.000Z",
"enabled": true,
"creditLimit": 1000,
"creditResetInterval": "monthly",
"expiresAt": null,
"usedQuotaCostCredit": 120,
"totalUsedCostCredit": 580,
"whitelistModelCount": 0,
"whitelistIpCount": 2,
"lastUsedAt": "2026-06-10T12:30:00.000Z",
"tags": ["prod"],
"employeeNo": "E001",
"orgUserDisplayName": "张三"
}
],
"total": 1,
"page": 1,
"pageSize": 20
}
分页字段:
| 字段 | 类型 | 说明 |
|---|---|---|
items | array | 当前页 Key 对象列表 |
total | number | 符合条件的总条数 |
page | number | 当前页码 |
pageSize | number | 每页条数 |
单条详情
curl -sS "https://www.51kik.com/openapi/api-keys/123" \
-H "X-Access-Token: $ACCESS_TOKEN"
成功时 data 为单个 Key 对象(字段见上文)。密钥不存在时返回 HTTP 404。
创建
curl -sS -X POST "https://www.51kik.com/openapi/api-keys" \
-H "X-Access-Token: $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"description": "automation-key",
"creditLimit": 500,
"creditResetInterval": "monthly",
"expiration": "never",
"tags": ["automation"],
"employee_no": "E001"
}'
Body 字段(均可选):
| 字段 | 类型 | 说明 |
|---|---|---|
description | string | 备注,最长 128 字符 |
creditLimit | number | null | 费用额度上限(credits);null 表示不限;默认 null |
creditResetInterval | string | none / daily / weekly / monthly;默认 none |
expiration | string | never / 1h / 1d / 7d / 30d / 90d / 180d / 1y;默认 never |
tags | string[] | 标签,最多 20 个 |
employee_no | string | 绑定组织成员(工号);工号不存在时不绑定(静默忽略) |
成功时 data 示例:
{
"id": 123,
"apiKey": "sk-xxxxxxxxxxxxxxxx",
"description": "automation-key"
}
| 字段 | 类型 | 说明 |
|---|---|---|
id | number | 新创建的密钥 ID |
apiKey | string | 完整明文密钥(仅此次响应返回) |
description | string | 备注 |
更新
curl -sS -X PATCH "https://www.51kik.com/openapi/api-keys/123" \
-H "X-Access-Token: $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"enabled": false, "description": "disabled-key"}'
Body 字段(至少传一个):
| 字段 | 类型 | 说明 |
|---|---|---|
description | string | 备注,最长 128 字符 |
enabled | boolean | 是否启用 |
creditLimit | number | null | 费用额度上限(credits);null 表示不限 |
creditResetInterval | string | none / daily / weekly / monthly |
expiration | string | never / 1h / 1d / 7d / 30d / 90d / 180d / 1y |
tags | string[] | 标签整包替换,最多 20 个 |
clearOrgEmployee | boolean | 为 true 时解除组织成员绑定 |
employee_no | string | 重新绑定成员工号;传空字符串等价于解除绑定;工号不存在时返回 HTTP 400 |
成功时 data 为更新后的 Key 对象。密钥不存在时返回 HTTP 404。
删除
curl -sS -X DELETE "https://www.51kik.com/openapi/api-keys/123" \
-H "X-Access-Token: $ACCESS_TOKEN"
成功时 data 为 { "id": 123 }。密钥不存在时返回 HTTP 400。
获取明文
curl -sS "https://www.51kik.com/openapi/api-keys/123/plaintext" \
-H "X-Access-Token: $ACCESS_TOKEN"
成功时 data 示例:
{
"id": 123,
"apiKey": "sk-xxxxxxxxxxxxxxxx"
}
| 字段 | 类型 | 说明 |
|---|---|---|
id | number | 密钥 ID |
apiKey | string | 完整明文密钥 |
密钥不存在时返回 HTTP 400。
错误
| HTTP | code | 场景 |
|---|---|---|
| 401 | 401 | 未携带 X-Access-Token,或令牌无效 / 已禁用 / 已过期 |
| 400 | 400 | Query / Body 格式错误;空 PATCH body;工号不存在;删除或获取明文时密钥不存在 |
| 404 | 404 | GET 详情或 PATCH 时密钥 id 不存在 |
相关
- 推理调用方式:API 密钥
- OpenAPI 概览