认证与 API Key
认证原理
Westtree 使用 Bearer Token 认证。在 Authorization 头中传递你的 API Key。
密钥安全
- 永远不要将密钥提交到版本控制
- 使用环境变量
- 定期轮换密钥
示例
curl https://api.westtree.top/v1/chat/completions
-H "Authorization: Bearer 你的_API_KEY"
-H "Content-Type: application/json"
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "你好"}]}'