OpenAI 检索管理员API密钥
检索管理员 API 密钥
get /organization/admin_api_keys/{key_id}
检索单个组织 API 密钥。
路径参数
key_id: string
API 密钥的 ID。
返回值
译注:本节按官方字段说明保留
owner.object、owner.role、owner.type的描述。官方列表页另一个响应示例使用organization.service_account、member、service_account,与这些描述存在口径差异;不能据此将服务账户改写为用户,或将角色强制改为owner。示例与协议值均保留原样。
AdminAPIKey object { id, created_at, expires_at, 5 more }
表示组织中的单个管理员 API 密钥。
id: string
可在 API 端点中引用的标识符。
created_at: integer
API 密钥创建时的 Unix 时间戳,单位为秒。
format: unixtime
expires_at: integer or null
API 密钥过期时的 Unix 时间戳,单位为秒。
format: unixtime
object: "organization.admin_api_key"
对象类型,始终为 organization.admin_api_key。
"organization.admin_api_key"
owner: object { id, created_at, name, 3 more }
id: optional string
可在 API 端点中引用的标识符。
created_at: optional integer
用户创建时的 Unix 时间戳,单位为秒。
format: unixtime
name: optional string
用户的名称。
object: optional string
对象类型,始终为 organization.user。
role: optional string
始终为 owner。
type: optional string
始终为 user。
redacted_value: string
API 密钥经遮蔽处理后的值。
last_used_at: optional integer or null
上次使用 API 密钥时的 Unix 时间戳,单位为秒。
format: unixtime
name: optional string or null
API 密钥的名称。
示例
## 从环境变量 OPENAI_ADMIN_KEY 读取管理员密钥;运行前替换示例密钥 ID 和名称。
curl https://api.openai.com/v1/organization/admin_api_keys/$KEY_ID \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"
200:示例
{
"id": "key_abc",
"created_at": 1711471533,
"expires_at": 1714063533,
"object": "organization.admin_api_key",
"owner": {
"id": "sa_456",
"created_at": 1711471533,
"name": "示例服务账户",
"object": "organization.user",
"role": "owner",
"type": "user"
},
"redacted_value": "sk-admin...def",
"last_used_at": 1711471534,
"name": "管理员密钥"
}
示例
## 从环境变量 OPENAI_ADMIN_KEY 读取管理员密钥;运行前替换示例密钥 ID 和名称。
curl https://api.openai.com/v1/organization/admin_api_keys/key_abc \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json"
响应示例
{
"object": "organization.admin_api_key",
"id": "key_abc",
"name": "主要管理员密钥",
"redacted_value": "sk-admin...xyz",
"created_at": 1711471533,
"expires_at": null,
"last_used_at": 1711471534,
"owner": {
"type": "user",
"object": "organization.user",
"id": "user_123",
"name": "张三",
"created_at": 1711471533,
"role": "owner"
}
}
TRAE-AI编程


更多建议: