Chat对话API 返回结果示例 xml {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268190,"model":"xxxchat", "choices":[{"index":0,"delta":{"role":"assistant"},"finishreason":null}]} {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268190,"model":"xxxchat", "choices":[{"index":0,"delta":{"content":"Hello"},"finishreason":null}]} .... {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268190,"model":"xxxchat", "choices":[{"index":0,"delta":{},"finishreason":"stop"}]} streamoptions.includeusage 为 True 时多返回一条包含usage流式消息。 xml {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268199,"model":"xxxchat", "choices":[], "usage": {"prompttokens": 9,"completiontokens": 120,"totaltokens": 129}} 流式异常返回 流式异常分为两种: ● 如果在流式请求接收处理之前发生了异常,如鉴权、参数校验等问题,与普通的非流式一样返回http code,并带有error结构。 ● 如果在流式请求已经接收,会先对外返回流式请求连接建立的信息,此时http code为200,而在后续模型流式返回过程中发生了异常,会在流式返回的chunk返回error结构,并终止当前的流式请求。 流式请求建立后的异常返回示例 xml {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268190,"model":"xxxchat", "choices":[{"index":0,"delta":{"role":"assistant"},"finishreason":null}]} {"id":"chatcmpl123","object":"chat.completion.chunk","created":1694268190,"model":"xxxchat", "choices":[{"index":0,"delta":{"content":"Hello"},"finishreason":null}]} .... {"error":{"code":"500001","type":"INVOKEMODELERROR","message":"服务接口异常,请联系管理员"}} 请求示例代码 plaintext 假设平台用户组AppKey884c8fc4054548a7b1ca1123592f5b7,模型ID96dcaaaaaaaaaaaa5ff55ea377831a,以此为例进行说明。