大模型配置

最近更新时间:2025-09-09 14:42:21

我的收藏
本文主要介绍如何在 开始AI对话任务 StartAIConversation 接口中配置 LLMConfig 参数。
OpenAl 标准协议
腾讯云智能体开发平台
Dify
Coze
说明:
支持任何符合 OpenAI 标准协议的 LLM 模型,LLMType 填写 openai,其他参数根据实际情况填写即可。

参数说明

名称
类型
是否必填
描述
LLMType
String
大模型类型,只要是符合 OpenAI API 协议的大模型,都填写openai
Model
String
具体的模型名称,例如 gpt-4o、deepseek-chat。
APIKey
String
大模型的 APIKey。
APIUrl
String
大模型的 APIUrl。
Streaming
Boolean
是否流式,默认为false,建议填true
SystemPrompt
String
系统提示词。
Timeout
Float
超时时间,取值范围 [1~50], 默认为 3 秒(单位:秒)。
History
Integer
设置 LLM 的上下文轮次,默认值:0(不提供上下文管理),最大值:50(提供最近 50 轮的上下文管理)。
MaxTokens
Integer
输出文本的最大 token 限制。
Temperature
Float
采样温度。
TopP
Float
采样的选择范围,控制输出 token 的多样性。
ExtraBody
Object
额外透传给大模型的参数,例如关闭思考:
{
"enable_thinking": false
}
UserMessages
Object[]
用户提示词,提供把更多上下文信息提供给大模型,帮助大模型更好地理解任务需求。
MetaInfo
Object
自定义参数,会放在请求的 body 中透传给大模型。

配置示例

OpenAI 标准规范

"LLMConfig": {
"LLMType": "openai",
"Model": "gpt-4o",
"APIKey": "api-key",
"APIUrl": "https://api.openai.com/v1/chat/completions",
"Streaming": true,
"SystemPrompt": "你是一个个人助手",
"Timeout": 3.0,
"History": 5,
"MetaInfo": {},
"MaxTokens": 4096,
"Temperature": 0.8,
"TopP": 0.8,
"UserMessages": [
{
"Role": "user",
"Content": "content"
},
{
"Role": "assistant",
"Content": "content"
}
],
"ExtraBody": {
"enable_thinking":false
}
}

MiniMax

"LLMConfig":{
"LLMType": "openai",
"Model": "abab6.5s-chat",
"Streaming": true,
"SystemPrompt": "你是一个个人助手",
"APIKey": "eyJhbGcixxxx",
"APIUrl": "https://api.minimax.chat/v1/text/chatcompletion_v2",
"History": 5,
"MetaInfo": {}
}

混元

"LLMConfig":{
"LLMType": "openai",
"Model": "hunyuan-standard", // hunyuan-turbo、hunyuan-standard
"APIKey": "hunyuan-apikey",
"APIUrl": "https://hunyuan.cloud.tencent.com/openai/v1/chat/completions",
"Streaming": true,
"History": 10,
"MetaInfo": {}
}
说明:
用于对接腾讯云智能体开发平台,具体可参考官方文档

参数说明

名称
类型
是否必填
描述
LLMType
String
大模型类型,使用腾讯云智能体开发平台时,请填写tencent_lke
APIKey
String
对应 LKE 产品应用发布得到的appkey
APIUrl
String
可以不传,默认使用https://wss.lke.cloud.tencent.com/v1/qbot/chat/sse
Timeout
Float
超时时间,取值范围 [1~50], 默认为 3 秒(单位:秒)。
FileInfos
Object[]
文件信息,对应file_infos
VisitorLabels
Object[]
知识标签(用于知识库中知识的检索过滤),对应visitor_labels
StreamingThrottle
Int
流式回复频率控制,对应streaming_throttle
CustomVariables
Object
自定义API参数的值,对应custom_variables
SystemRole
String
角色指令(提示词),对应system_role
SessionId
String
会话 ID,用于标识一个会话,对应session_id
VisitorBizId
String
访客 ID,对应visitor_biz_id
说明:
扩展参数的使用请详细阅读对话端接口文档(HTTP SSE)

配置示例

"LLMConfig": {
"LLMType": "tencent_lke",
"APIUrl": "https://wss.lke.cloud.tencent.com/v1/qbot/chat/sse",
"APIKey": "xxxxx",
"Timeout": 10.0,
"FileInfos": [],
"VisitorLabels":[],
"StreamingThrottle":5,
"CustomVariables":{},
"SystemRole":"",
"SessionId":"",
"VisitorBizId":""
}
说明:
用于对接Dify,具体可参考官方文档

参数说明

名称
类型
是否必填
描述
LLMType
String
大模型类型,使用 Dify 时,请填写dify
APIKey
String
Dify 的 API 密钥。
APIUrl
String
选填,默认使用https://api.dify.ai/v1/chat-messages
Timeout
Float
超时时间,取值范围 [1~50], 默认为 3 秒(单位:秒)。
Streaming
Boolean
是否流式,默认为false,建议填true
Inputs
Object
Dify LLM 请求 body 中的inputs参数,不填默认为{}。
User
String
Dify LLM 请求 body 中的user参数,不填则默认填充为此次taskid
ConversationId
String
建议不填,AI 对话默认支持conversation_id,如果不填会自动创建conversation_id

配置示例

"LLMConfig": {
"LLMType": "dify", // 必填,llm类型
"APIKey": "your-secret-key", // 必填,dify的api密钥
"APIUrl": "https://api.dify.ai/v1/chat-messages", // 选填,默认"https://api.dify.ai/v1/chat-messages"
"Timeout": 10.0,
"Streaming": true, // 选填,是否流式,默认为false,建议填true
"Inputs": {}, // 选填,dify llm请求body中的inputs参数,不填默认为{}
"User": "your-user-id" // 选填,dify llm请求body中的user参数,不填则默认填充为此次taskid
"ConversationId": "" // 选填,建议不填,AI对话默认支持conversation_id,如果不填会自动创建 conversation_id
}
说明:
用于对接Coze,具体可参考官方文档(国内)官方文档(国际)

参数说明

名称
类型
是否必填
描述
LLMType
String
大模型类型,使用 Coze 时,请填写coze
APIKey
String
Coze 的secret token
BotId
String
Coze 的botid
APIUrl
String
选填,默认使用https://api.coze.cn/v3/chat;如果是国外平台账号,请使用https://api.coze.com/v3/chat
Timeout
Float
超时时间,取值范围 [1~50], 默认为 3 秒(单位:秒)。
Streaming
Boolean
固定填true,Coze 暂时不支持非流式。
UserId
String
Coze LLM 请求 body 中的user_id参数,不填则默认填充为此次taskid

配置示例

"LLMConfig": {
"LLMType": "coze", // 必填,llm类型
"APIKey": "your-secret-key", // 必填,coze的secret token
"Streaming": true, // 固定填true,coze暂时不支持非流式
"Timeout": 10.0,
"BotId": "botid", // 必填,coze的botid
"UserId": "your-user-id" // 选填,coze llm请求body中的user_id参数,不填则默认填充为此次taskid
"APIUrl": "https://api.coze.cn/v3/chat" // 选填,默认为https://api.coze.cn/v3/chat,如果是国外平台账号,则填写https://api.coze.com/v3/chat
}

大模型的请求

此外我们会在 HTTP header 中增加多个参数来辅助用户支持更复杂的逻辑:
X-Task-Id: <task_id_value> // 此任务的 id,
X-Request-Id: <request_id> // 此次请求的id, 重试会携带相同的requestId
X-Sdk-App-IdSdkAppId
X-User-IdUserId
X-Room-IdRoomId
X-Room-Id-Type: "0" // "0"表示数字房间号 "1"表示字符串房间号