Completions(旧版)
兼容 OpenAI 旧版 Completions API。新代码请使用 Chat Completions;保留此接口仅为向下兼容遗留集成。
POST https://api.wrouter.io/v1/completions请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✓ | 例如 gpt-3.5-turbo-instruct、davinci-002 |
prompt | string | string[] | ✓ | 输入文本 |
max_tokens | integer | ||
temperature | number | ||
top_p | number | ||
n | integer | ||
stream | boolean | ||
stop | string | string[] | ||
suffix | string | ||
echo | boolean |
响应
json
{
"id": "cmpl-xxx",
"object": "text_completion",
"created": 1718000000,
"model": "gpt-3.5-turbo-instruct",
"choices": [{"text": "...", "index": 0, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 5, "completion_tokens": 7, "total_tokens": 12}
}示例
bash
curl https://api.wrouter.io/v1/completions \
-H "Authorization: Bearer $WROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-3.5-turbo-instruct","prompt":"hello, ","max_tokens":16}'