接口文档 接口信息 API Path /aipaas/lm/v1/telechat/ty36b 请求协议 HTTP 请求方法 POST 请求头部: 头部标签 必填 说明 类型 数据字典 限制 头部内容 示例 ContentType 是 application/json;UTF8 [string] application/json application/json XAPPID 是 系统管理API Key,创建应用获取AppID 和AppKey,公网鉴权,公网调用时必传 [string] DeviceUuid 否 设备管理设备uuid [string] Authorization 是 鉴权信息 [string] 请求参数 Json Object 参数名 说明 必填 类型 数据字典 限制 示例 messages 对话内容。多轮对话场景下,完整的content长度不可超过模型最大输入。(聊天中content可为空) 是 [array] messages>>content string/array,消息的内容 是 [string] messages>>refusal 助理的拒绝消息 否 [string] messages>>role 消息作者的角色 是 [string] messages>>name 参与者的可选名称。提供模型信息以区分同 一角色的参与者,最大长度为 30 否 [string] messages>>toolcalls 模型生成的工具调用 否 [array] messages>>toolcalls>>id 工具调用的 ID 是 [string] messages>>toolcalls>>type 工具的类型。【目前仅支持 function,未严格校验】 是 [string] messages>>toolcalls>>function 模型调用的函数。 是 [object] messages>>toolcalls>>function>>name 要调用的函数的名称 是 [string] messages>>toolcalls>>function>>arguments string/obj,用于调用函数的参数,由模型生成。【标准是string类型,推荐使用string】 是 [string] messages>>toolcallid 此消息正在响应的工具调用,最大长度 为 64 否 [string] model 要使用的模型的 ID(Chat),最大长度为 64 是 [string] maxcompletiontokens 最大生成词元数量。输入词元和生成词元的 总长度受模型上下文长度的限制。兼容传入maxtokens,但不允许两个参数同时存在,范围在 1 到模型最大输出长度(例如:2000) 否 [int] presencepenalty 默认值为 0,在 2.0 到 2.0 之间。正值会基于新生成词是否已经出现在当前文本中进行惩罚,增加模型谈论新主题的可能性。 否 [number] stream 默认值为 false,如果设置true,回答内容将使用流式传输。 否 [boolean] streamoptions 流式响应的选项。仅当您设置stream: true时设置此项才生效。 "streamoptions":{"includeusage": true} 如果设置,则在data: [DONE]之前流式传输的一个块中usage此块上的字段显示整个请求的token使用情况统计信息。 否 [object] tools 模型可以调用的工具列表【模型中工具传入,在生成时候不一定会调用】 否 [array] tools>>type 工具的类型。目前仅支持 function 是 [string] tools>>function 模型调用的函数 是 [object] tools>>function>>description 函数用途的描述,模型使用它来选择何时以 及如何调用函数,最大长度 2000 否 [string] tools>>function>>name 要调用的函数的名称。必须是 az、AZ、09 或包含下划线和短划线,最大长度为 64 是 [string] tools>>function>>parameters 函数接受的参数,描述为 JSON Schema 对 象。请参阅 指南 有关示例,请参阅 JSON 架构参考 有关格式的文档 否 [object] tools>>function>>strict 是否在生成函数调用时启用严格的架构遵 循。如果设置为 true,则模型将遵循字段中定义的确切架构。当 is 时,仅支持 JSON 架构的子集。在函数调用指南中了解有关结构化输出的更多信息 否 [boolean] toolchoice 控制模型调用工具。 none 表示模型不会调 用任何工具,而是生成一条消息。 auto 表示模型可以在生成消息或调用一个或多个工具之间进行选择 否 [string] temperature 默认值为 0.3,使用的采样温度,范围 [0,2]。较高的值如 0.8 会使输出更随机,而较低的值如 0.2 会使输出更集中且具有确定性,取 0 时会关闭采样,无随机输出。 否 [number] topp 默认值为 1,取值范围为[0,1]之间,作为温 度采样的替代方法,称为核采样,该方法中模型考虑具有 topp 概率质量的词元结果 否 [number] extrabody 额外参数 否 [object] extrabody>>topk 作用:随机候选数(不建议修改) 取值:大于 0 的值越大,输出的多元性越大。 取值范围:(0,10000] 否 [int] extrabody>>repetitionpenalty 作用:生成重复惩罚 取值范围:(0,2] 否 [double] extrabody>>frequencypenalty 基于它们在生成文本中的频率。 值>0 鼓励模型使用新令牌,而值 >id 聊天补全的唯一标识符(uuid4)。 是 [string] data>>choices 聊天补全选项的列表。 是 [array] data>>choices>>finishreason string/null,模型停止生成标记的原因。原因可能是stop模型到达自然停止点或提供的停止序列、 length达到请求中指定的最大标记数。 否 [string] data>>choices>>index 选择列表中的索引 否 [int] data>>choices>>delta 模型响应流生成的聊天补全增量。 否 [object] data>>choices>>delta>>content string/null,块消息的内容。 否 [string] data>>choices>>delta>>role 此消息作者的角色。【第一块携带、其他块不携带此参数】 否 [string] data>>choices>>delta>>refusal string/null,模型生成的拒绝消息【第一块携带、其他 块不携带此参数】 否 [string] data>>choices>>delta>>toolcalls 工具列表 否 [array] data>>choices>>delta>>toolcalls>>index 选择列表中的索引 否 [int] data>>choices>>delta>>toolcalls>>id 工具调用的 ID 否 [string] data>>choices>>delta>>toolcalls>>type 工具的类型。目前仅支持 function 否 [string] data>>choices>>delta>>toolcalls>>function 模型调用的函数。 否 [object] data>>choices>>delta>>toolcalls>>function>>name 要调用的函数的名称 否 [string] data>>choices>>delta>>toolcalls>>function>>arguments 用于调用函数的参数,由模型以 JSON 格式生成。请注意,该模型并不总是生成有效的 JSON,并且可能会产生函数架构未定义的参数。在调用函数之前验证代码中的参数 否 [string] data>>choices>>logprobs object/null,输出标记的对数概率。 否 [object] data>>created 时间戳【秒级】 是 [int] data>>model 用于生成补全的模型。 是 [string] data>>object 对象类型,始终为 chat.completion.chunk。 是 [string] data>>usage object/null,token 统计【当 streamoptions 生效时,流式最后一个块携带 usage 信息,其他情况默认不携带】 否 [object] data>>usage>>completiontokens 生成tokens 否 [int] data>>usage>>prompttokens prompt的tokens 否 [int] data>>usage>>totaltokens 总tokens 否 [int] data>>usage>>completiontokensdetails 生成 tokens 详细统计 否 [object] data>>usage>>completiontokensdetails>>reasoningtokens 思考 tokens,当前都为 0 否 [int] data>>systemfingerprint 代表模型运行时后端配置的指纹。【当前默认null】 是 [string] 非流式响应结果成功 (200) Json Object 参数名 说明 必填 类型 数据字典 限制 示例 id 聊天补全的唯一标识符(uuid4)。 是 [string] choices 聊天补全选项的列表。 是 [array] choices>>finishreason 模型停止生成标记的原因。原因可能是stop模型到达自然停止点或提供的停止序列、 length达到请求中指定的最大标记数。 如果模型调用了工具,toolcalls。 是 [string] choices>>index 选择列表中的索引 是 [int] choices>>message 模型生成的聊天补全消息。 是 [object] choices>>message>>content 消息的内容 是 [string] choices>>message>>refusal 模型生成的拒绝消息。 是 [string] choices>>message>>toolcalls 模型生成的工具调用,例如函数调用。 否 [array] choices>>message>>toolcalls>>id 工具调用的 ID。 否 [string] choices>>message>>toolcalls>>type 工具的类型。目前仅支持 function。 否 [string] choices>>message>>toolcalls>>function 模型调用的函数。 否 [object] choices>>message>>toolcalls>>function>>name 要调用的函数的名称。 否 [string] choices>>message>>toolcalls>>function>>arguments 用于调用函数的参数,由模型以 JSON 格式生成。请注意,该模型并不总是生成有效的 JSON,并且可能会产生函数架构未定义的参数。在调用函数之前验证代码中的参数。 否 [string] choices>>message>>role 此消息作者的角色。 是 [string] choices>>logprobs object/null,输出标记的对数概率。 是 [object] created 时间戳【秒级】 是 [int] model 用于聊天补全的模型。 是 [string] object 对象类型,始终为 chat.completion。 是 [string] chat.completion.chunk usage token统计 是 [object] usage>>completiontokens 生成tokens 是 [int] usage>>prompttokens prompt的tokens 是 [int] usage>>totaltokens 总tokens 是 [int] usage>>completiontokensdetails 生成 tokens 详细统计 是 [object] usage>>completiontokensdetails>>reasoningtokens 思考 tokens,当前都为 0 是 [int] systemfingerprint 代表模型运行时后端配置的指纹。【当前默认null】 是 [string] 成功示例[Mock API]: plaintext data: { "id": "277fd1f21c9e4b15bbbc6f28b0fc62ab", "choices": [{ "finishreason": null, "index": 0, "delta": { "content": "", "role": "assistant", "refusal": null }, "logprobs": null }], "created": 1729666765, "systemfingerprint": null, "model": "aichat", "object": "chat.completion.chunk" } data: { "id": "277fd1f21c9e4b15bbbc6f28b0fc62ab", "choices": [{ "finishreason": null, "index": 0, "delta": { "content": "你好" }, "logprobs": null }], "created": 1729666765, "model": "aichat", "systemfingerprint": null, "object": "chat.completion.chunk" } ........中间省略消息块 data: { "id": "277fd1f21c9e4b15bbbc6f28b0fc62ab", "choices": [{ "finishreason": null, "index": 0, "delta": { "content": "?" }, "logprobs": null }], "created": 1729666765, "model": "aichat", "systemfingerprint": null, "object": "chat.completion.chunk" } data: { "id": "277fd1f21c9e4b15bbbc6f28b0fc62ab", "choices": [{ "finishreason": "stop", "index": 0, "delta": {}, "logprobs": null }], "created": 1729666765, "model": "aichat", "systemfingerprint": null, "object": "chat.completion.chunk" } data: { "id": "c86aff51e90442ed8c7e1ab5296189a8", "choices": [], "created": 1729666822, "model": "aichat", "systemfingerprint": null, "object": "chat.completion.chunk", "usage": { "completiontokens": 40, "prompttokens": 23, "totaltokens": 63, "completiontokensdetails": { "reasoningtokens": 0 } } } 此消息块在streamoption生效时产生 data: [DONE]