平台与鉴权头对照
| 平台 | 鉴权头 | 备注 |
|---|---|---|
| OpenAI 及兼容生态 | Authorization: Bearer <key> | Bearer 后有空格 |
| Anthropic | x-api-key: <key> | 加 anthropic-version 头 |
| Azure OpenAI | api-key: <key> | 也可用 Entra ID Token |
| Gemini | x-goog-api-key: <key> | 或 ?key= 查询参数(不推荐) |
三种头写法(curl)
三种头写法(curl)
curl -s https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"
curl -s https://api.anthropic.com/v1/models -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01"
curl -s "https://RESOURCE.openai.azure.com/openai/models?api-version=2024-10-21" -H "api-key: $AZURE_OPENAI_KEY"API Key 只放环境变量或密钥管理服务;绝不进代码仓库、客户端包与日志。