cURL / HTTP
从终端直接调用 AllToken API。
基本请求
cURL
| 1 | curl https://api.alltoken.ai/v1/chat/completions \ |
| 2 | -H "Authorization: Bearer $ALLTOKEN_API_KEY" \ |
| 3 | -H "Content-Type: application/json" \ |
| 4 | -d '{ |
| 5 | "model": "deepseek-chat", |
| 6 | "messages": [ |
| 7 | {"role": "user", "content": "你好!"} |
| 8 | ] |
| 9 | }' |
使用 cURL 进行流式传输
添加 "stream": true 并使用 --no-buffer 即时查看 token:
cURL 流式
| 1 | curl --no-buffer https://api.alltoken.ai/v1/chat/completions \ |
| 2 | -H "Authorization: Bearer $ALLTOKEN_API_KEY" \ |
| 3 | -H "Content-Type: application/json" \ |
| 4 | -d '{ |
| 5 | "model": "deepseek-chat", |
| 6 | "stream": true, |
| 7 | "messages": [ |
| 8 | {"role": "user", "content": "给我讲个笑话"} |
| 9 | ] |
| 10 | }' |