创建文本补全
POST /v1/completions
基于给定提示创建文本补全
基本信息
| 项目 | 内容 |
|---|---|
| Base URL | https://www.yunzhuhub.cn |
| 标签 | 文本补全(Completions) |
| Operation ID | createCompletion |
认证
- BearerAuth:使用 Bearer Token 认证。 格式:
Authorization: Bearer sk-xxxxxx
密钥安全
请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。
参数
无额外路径或查询参数。
请求体
Content-Type: application/json
json
{
"title": "CompletionRequest",
"type": "object",
"required": [
"model",
"prompt"
],
"properties": {
"model": {
"type": "string"
},
"prompt": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"max_tokens": {
"type": "integer"
},
"temperature": {
"type": "number"
},
"top_p": {
"type": "number"
},
"n": {
"type": "integer"
},
"stream": {
"type": "boolean"
},
"stop": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"suffix": {
"type": "string"
},
"echo": {
"type": "boolean"
}
}
}请求示例
以下示例只用于复制到本地终端,不会从文档站发送请求。
bash
curl --request POST 'https://www.yunzhuhub.cn/v1/completions' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '<REQUEST_JSON>'响应
200 成功创建响应
json
{
"title": "CompletionResponse",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string",
"example": "text_completion"
},
"created": {
"type": "integer"
},
"model": {
"type": "string"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"index": {
"type": "integer"
},
"finish_reason": {
"type": "string"
}
}
}
},
"usage": {
"$ref": "#/components/schemas/Usage"
}
}
}