创建文本补全
post/v1/completions
基于给定提示创建文本补全
鉴权
把 OLETOKEN 的 API Key 作为 Bearer Token 放进 Authorization 请求头。密钥在控制台的「API 密钥」页创建。
Authorization: Bearer $OLETOKEN_API_KEY请求体
Content-Type:application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | — | |
| prompt | string | string[] | — | |
| max_tokens | integer | — | — |
| temperature | number | — | — |
| top_p | number | — | — |
| n | integer | — | — |
| stream | boolean | — | — |
| stop | string | string[] | — | — |
| suffix | string | — | — |
| echo | boolean | — | — |
响应
200成功创建响应
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | — | — |
| object | string | — | — |
| created | integer | — | — |
| model | string | — | — |
| choices | object[] | — | — |
| text | string | — | — |
| index | integer | — | — |
| finish_reason | string | — | — |
| usage | Usage | — | — |
| prompt_tokens | integer | — | 提示词 Token 数 |
| completion_tokens | integer | — | 补全 Token 数 |
| total_tokens | integer | — | 总 Token 数 |
| prompt_tokens_details | object | — | — |
| cached_tokens | integer | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| image_tokens | integer | — | — |
| completion_tokens_details | object | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| reasoning_tokens | integer | — | — |
请求示例
curl -X POST 'https://api.oletoken.ai/v1/completions' \
-H "Authorization: Bearer $OLETOKEN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "string",
"prompt": "string"
}'
