请求与字段#
Endpoint
POST https://api.shrimpapi.example/v1/chat/completions| 字段 | 说明 |
|---|---|
| model / messages | 必填;消息可包含 system、user、assistant、tool。 |
| stream | true 开启 SSE。 |
| stream_options | 可启用 include_usage。 |
| max_tokens / max_completion_tokens | 输出上限。 |
| tools / tool_choice / response_format | 工具与结构化输出。 |
| temperature / top_p / stop | 采样与停止控制。 |
使用 Bearer Key 鉴权与 JSON 请求体。
调用示例#
cURL · Chat Completions
curl https://api.shrimpapi.example/v1/chat/completions \
-H "Authorization: Bearer sk-YOUR_SHRIMPAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6.2-sol","messages":[{"role":"user","content":"你好"}]}'流式用量#
JSON · include_usage
{
"model": "gpt-6.2-sol",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [{ "role": "user", "content": "你好" }]
}开启后,在流结束前增加包含 usage 的数据帧。计费使用真实用量,不依赖客户端是否请求这一帧。
响应与档位#
非流式内容在 choices[0].message,流式增量在 choices[0].delta,结束标识为 data: [DONE]。
此接口的超快档使用 service_tier: "ultrafast";priority 不启用快速档。