Mangogo 营业厅Mangogo 营业厅
首页API 参考Skills插件

POST /v1/completions

POST/v1/completions

Legacy 文本补全接口。

鉴权:Bearer Token

Content-Type:application/json

请求体

{  "model": "gpt-4o",  "prompt": "Say this is a test",  "max_tokens": 100,  "temperature": 0.7,  "stream": false}

请求字段

字段类型必填说明
modelstring是模型 ID
promptstring / array是提示文本
max_tokensinteger否最大输出 Token 数
temperaturenumber否采样温度
top_pnumber否核采样
ninteger否生成数量,默认 1
streamboolean否是否流式
stopstring / array否停止序列

请求示例(curl)

非流式:

curl https://www.yunsell.com/v1/completions \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4o",    "prompt": "Say this is a test",    "max_tokens": 100,    "temperature": 0.7,    "stream": false  }'

流式(SSE):

curl -N https://www.yunsell.com/v1/completions \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4o",    "prompt": "Say this is a test",    "stream": true  }'

响应体(非流式)

HTTP 200

{  "id": "cmpl-abc123",  "object": "text_completion",  "created": 1712697600,  "model": "gpt-4o",  "choices": [    {      "index": 0,      "text": "This is indeed a test.",      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 5,    "completion_tokens": 6,    "total_tokens": 11  }}

响应字段

字段类型说明
idstring响应 ID,如 cmpl-xxx
objectstring固定为 text_completion
createdintegerUnix 时间戳(秒)
modelstring使用的模型
choicesarray生成结果列表
choices[].indexinteger结果索引
choices[].textstring补全文本
choices[].finish_reasonstringstop / length / content_filter
usageobjectToken 用量,见 公共响应对象

响应体(流式)

data: {"id":"cmpl-abc123","object":"text_completion","created":1712697600,"choices":[{"index":0,"text":"This","finish_reason":null}]}data: {"id":"cmpl-abc123","object":"text_completion","created":1712697600,"choices":[{"index":0,"text":" is","finish_reason":null}]}data: [DONE]

流式 chunk 字段

字段类型说明
idstring响应 ID
objectstring固定为 text_completion
createdintegerUnix 时间戳(秒)
choices[].indexinteger结果索引
choices[].textstring增量文本片段
choices[].finish_reasonstring / null末条 chunk 为结束原因