Chat对话API 返回结果示例 xml { "id": "chatcmpl123", "object": "chat.completion", "created": 1677652288, "model": "xxxchat", "choices": [{ "index": 0, "finishreason": "stop", "message": { "role": "assistant", "content": "nnHello there, how may I assist you today?" } }], "usage": { "prompttokens": 9, "completiontokens": 12, "totaltokens": 21 } } 非流式异常返回 非流式异常返回时: ● http code 返回非200。 ● http body 中返回 error 结构,error结构中包含code、type、message、param等信息,具体可见错误处理章节内容。 错误结果示例 xml { "error" : { "code" : "500001", "type" : "INVOKEMODELERROR", "message" : "服务接口异常,请联系管理员" } } 流式返回 流式正常返回 字段名称 二级字段 三级字段 字段类型 描述 id string 唯一标识符 choices string choices列表 index int choice索引 delta object 模型生成的消息 role string 对话角色 content string 对话消息内容 finishreason string 模型停止生成标记的原因。 stop: 模型生成遇到自然停止点或提供的停止序列; length: 达到请求中指定的最大标记数; contentfilter:如果由于内容过滤器中的标志而省略了内容 toolcalls/functioncall: 模型调用了函数。 created int Unix时间戳(以秒为单位)。 model string 调用的模型名称。 object string 返回的对象类型。流式返回始终为:chat.completion.chunk usage object 请求使用情况的统计信息。 仅在streamoptions: {"includeusage": true}设置时显示。如果存在,则它包含一个 null 值,但最后一个块包含整个请求的token使用情况的统计信息。 completiontokens int 生成token数。 prompttokens int 输入token数。 totaltokens int 使用的token总数(prompt + completion)。