cURL 示例
cURL 是最快速验证 API 的方式,无需安装任何依赖。
基础对话请求
bash
curl https://beesai.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "你好"}]
}'流式输出 (SSE)
bash
curl https://beesai.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "讲一个笑话"}],
"stream": true
}'查看可用模型
bash
curl https://beesai.cn/v1/models \
-H "Authorization: Bearer sk-你的API_KEY"调试技巧
查看完整响应头
bash
curl -i https://beesai.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的API_KEY" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}'格式化 JSON 输出
bash
curl -s https://beesai.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-你的API_KEY" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}' | python3 -m json.tool