codecamp

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"
  }
}
OpenAI 创建管理员API密钥
OpenAI 删除管理员API密钥
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

其他能力与进阶指南

Embeddings 接口参考

审计日志接口参考

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }