OpenAI API Key 教學:platform.openai.com 帳號、Billing、Secret Key 與用量限制

platform 帳號 → Billing → Secret Key → 冒煙請求 → Limits 與 429。

你要拿到可用于代码与集成的 OpenAI API Key,而不只是 chatgpt.com 网页聊天。官方路径:platform.openai.com 账号 → Settings → Billing 開通按量計費 → Settings → API keys 建立 Secret Key → 在 Usage 与 Limits 查看 RPM/TPM 上限。步骤以 Quickstart、Authentication、Rate limits 为准。

可檢索主题是 OpenAI API Key:platform.openai.com 账号、Billing、建立 Secret Key、用量与限速基础。以控制台 Billing、Usage、Limits 为准,不用第三方額度表。ChatGPT Plus 不包含 API 額度。

账号註冊 → 組織 Dashboard
Secret KeyAPI keys · 仅顯示一次
LimitsRPM · TPM · 用量档位

平台与 ChatGPT 的区别

platform.openai.com

开发者控制台:Billing、API keys、Usage、Limits。REST 请求发往 api.openai.com。

chatgpt.com

面向消费者的 ChatGPT。Plus 訂閱不是 API 額度;API 按 token 单独計費(Pricing)。

步骤控制台位置常見卡点
建立账号platform.openai.com 註冊驗證邮箱;地域规则以註冊页为准
開通 BillingSettings → Billing按量调用需 Billing 就绪(Managing billing)
建立 Secret KeySettings → API keys → Create完整金鑰只顯示一次;外洩即撤銷并輪換
查看限额Settings → Limits · Usage各模型 RPM/TPM;档位见 Usage tiers

账号、Billing 与 Secret Key

  1. 01
    註冊 platform.openai.com 账号

    用邮箱或支持的 OAuth 註冊,驗證邮箱后进入 Dashboard。Quickstart 第一步即 Sign up / Log in。團隊可在一个 Organization 下协作并邀请成员。

  2. 02
    設定 Billing

    打开 Settings → Billing,为組織添加支持的支付方式并開通按量計費。API 按 token 計費(Pricing)。发票与用量在此管理,不在 chatgpt.com 的 Settings。

  3. 03
    建立 Secret API Key

    Settings → API keys → Create new secret key。立即复制到密碼管理器。Authentication 文档要求 Bearer 头,禁止写入 Git 或前端 bundle。不同应用用不同金鑰,便于单独撤銷。

  4. 04
    冒烟测试一条请求

    在本地設定 $OPENAI_API_KEY,向 https://api.openai.com/v1/chat/completions POST,或使用 Playground。成功时 choices[0].message.content 有回复且 Usage 增加。

  5. 05
    读懂用量与限速基础

    Rate limits 说明 RPM 与 TPM。关注 x-ratelimit-remaining-* 回應头。429 时遵守 retry-after 或降低並行。Settings → Limits 顯示組織長期上限。

export OPENAI_API_KEY="sk-..."  # 切勿提交到 Git

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Say hello in one word."}]
  }'

常見失敗点

401 Unauthorized
金鑰缺失、拼错或已撤銷。检查 Authorization: Bearer 与 API keys 页的 Active 状态。
429 Too Many Requests
触达 RPM/TPM。读回應头与 retry-after;Rate limits 文档建议指数退避。
403 或 model not found
当前 Usage tier 可能不含该模型。换 Quickstart 默认模型或查看 Limits。
Billing 未就绪
调用失敗或 Usage 始终为零——打开 Settings → Billing 确认組織計費状态。

金鑰外洩先輪換,再讨论模型。一条最小请求加 Usage 比盲目接 IDE 更快确认 Billing 与 Limits。

團隊要对齐集成方案时

OpenAI API 是 HTTP;Copilot 或 Cursor Agent 是另一条路。把 endpoint、模型与 Limits 截图攤在同一页。oakmeet 临时房间:浏览器、空间码、無需註冊。上限见 八人、大约一小时。對照 ChatGPT Plus、Google AI Studio、Cline 自備 Key。

ChatGPT Plus 包含 API 額度吗?

不包含。Plus 在 chatgpt.com;API 在 platform.openai.com 单独按量計費。见 Pricing 与 Managing billing Help。

如何先看用量再放量?

用控制台 Settings → Billing 与 Usage。團隊约定以 Limits 与模型选择为准,勿信非官方額度文。

Secret Key 外洩怎么办?

立即在 Settings → API keys 撤銷并新建。Authentication 文档建议定期輪換、按项目分金鑰。

如何提高 rate limits?

上限与 Usage tier 相关(Usage tiers)。在 Settings → Limits 查看組織档位与页面提供的升级路径。

立即開會