codecamp

OpenAI 获取项目 API 密钥

获取项目 API 密钥

get /organization/projects/{project_id}/api_keys/{api_key_id}

获取项目中的 API 密钥。

路径参数

  • project_id: string

项目 ID。

  • api_key_id: string

API 密钥 ID。

返回值

  • ProjectAPIKey object { id, created_at, last_used_at, 6 more }

表示项目中的单个 API 密钥。

  • id: string

标识符,可在 API 端点中引用。

  • created_at: integer

API 密钥创建时间的 Unix 时间戳,单位为秒。

format: unixtime

  • last_used_at: integer or null

API 密钥上次使用时间的 Unix 时间戳,单位为秒。

format: unixtime

  • name: string

API 密钥名称。

  • object: "organization.project.api_key"

对象类型,固定为 organization.project.api_key。

  • "organization.project.api_key"

  • owner: object { service_account, type, user }

  • service_account: optional object { id, created_at, name, role }

拥有项目 API 密钥的服务账户。

  • id: string

标识符,可在 API 端点中引用。

  • created_at: integer

服务账户创建时间的 Unix 时间戳,单位为秒。

format: unixtime

  • name: string

服务账户名称。

  • role: string

服务账户的项目角色。

  • type: optional "user" or "service_account"

user(用户)或 service_account(服务账户)。

  • "user"

  • "service_account"

  • user: optional object { id, created_at, email, 2 more }

拥有项目 API 密钥的用户。

  • id: string

标识符,可在 API 端点中引用。

  • created_at: integer

用户创建时间的 Unix 时间戳,单位为秒。

format: unixtime

  • email: string

用户的电子邮件地址。

  • name: string

用户名称。

  • role: string

用户的项目角色。

  • owner_project_access: "active" or "inactive"

API 密钥所有者当前是否对项目具有有效访问权限。

  • "active"

  • "inactive"

  • redacted_value: string

经过遮蔽的 API 密钥值。

  • expires_at: optional integer or null

API 密钥过期时间的 Unix 时间戳,单位为秒;不过期时为 null。

format: unixtime

示例

## 使用环境变量中的组织管理员密钥获取项目 API 密钥
curl "https://api.openai.com/v1/organization/projects/proj_abc/api_keys/key_abc" \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json"

响应示例

{
    "object": "organization.project.api_key",
    "redacted_value": "sk-abc...def",
    "name": "我的 API 密钥",
    "created_at": 1711471533,
    "last_used_at": 1711471534,
    "id": "key_abc",
    "owner_project_access": "active",
    "owner": {
        "type": "user",
        "user": {
            "id": "user_abc",
            "name": "示例用户",
            "email": "user@example.com",
            "role": "owner",
            "created_at": 1711471533
        }
    }
}
OpenAI 归档项目
OpenAI 更新项目 API 密钥
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

其他能力与进阶指南

Embeddings 接口参考

审计日志接口参考

项目管理及子资源接口参考

Agents 接口及子资源

Decisions 接口参考

关闭

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; }