开放平台应用
开放平台模块提供标准化的开放API接口,包括Chat Completion对话接口和开放平台应用管理接口。
Chat Completion V1
接口地址
POST /openapi/api/v1/chat/completions
请求方法
POST
权限要求
chat_v1 READ
接口描述
标准的Chat Completion接口,支持SSE流式输出和JSON响应。
请求Header
| Header名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | String | 是 | Bearer Token认证,格式:Bearer sk_xxxxxxxxxxxxx |
请求参数
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| userId | String | 否 | - | 用户ID |
| conversationId | String | 否 | - | 会话ID |
| prompt | String | 否 | - | 提示词文本 |
| promptTemplate | String | 否 | - | 提示词模板 |
| model | String | 否 | - | 模型名称 |
| ragSearch | boolean | 否 | true | 是否启用RAG检索 |
| reasonStatus | boolean | 否 | false | 是否返回推理状态 |
| messages | LinkedList<BotMessage> | 否 | - | 消息列表 |
| containerId | List<String> | 否 | - | 知识库容器ID列表 |
| multipleDialog | boolean | 否 | true | 是否多轮对话 |
| temperature | float | 否 | 0.95 | 温度参数,0-1 |
| top_p | float | 否 | 0.7 | Top P采样 |
| fileIds | List<String> | 否 | - | 文件ID列表 |
| apiKey | String | 否 | - | API Key(隐藏字段) |
BotMessage结构:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| role | String | 是 | 角色类型 |
| content | Object | 否 | 消息内容 |
| reasoningContent | String | 否 | 推理内容 |
RequestBody示例
{
"userId": "user_001",
"conversationId": "conv_001",
"prompt": "你好",
"model": "glm-4",
"ragSearch": true,
"reasonStatus": false,
"messages": [
{
"role": "user",
"content": "你好,请介绍一下自己"
}
],
"containerId": ["container_001"],
"multipleDialog": true,
"temperature": 0.95,
"top_p": 0.7,
"fileIds": []
}
响应示例
SSE流式或JSON响应:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "glm-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!我是智能助手,很高兴为您服务。"
},
"finish_reason": "stop"
}
]
}
请求示例
curl -X POST "${domain}/openapi/api/v1/chat/completions" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4",
"prompt": "你好",
"messages": [
{"role": "user", "content": "你好,请介绍一下自己"}
],
"containerId": ["container_001"],
"temperature": 0.95,
"top_p": 0.7
}'
查询可用模型列表
接口地址
GET /openapi/community/v1/models
请求方法
GET
权限要求
chat_v2 READ
接口描述
查询当前可用的模型列表,返回OpenAI兼容格式。
请求参数
无
响应示例
{
"object": "list",
"data": [
{
"id": "glm-4",
"object": "model",
"created": 1677652288,
"owned_by": "zhipu"
},
{
"id": "glm-3-turbo",
"object": "model",
"created": 1677652288,
"owned_by": "zhipu"
}
]
}
请求示例
curl -X GET "${domain}/openapi/community/v1/models" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json"
Chat OpenAI兼容接口
接口地址
POST /openapi/community/v1/chat/completions
请求方法
POST
权限要求
chat_v2 READ
接口描述
OpenAI兼容的Chat Completion接口V2,支持SSE流式输出和JSON响应。
请求Header
| Header名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | String | 是 | Bearer Token认证,格式:Bearer sk_xxxxxxxxxxxxx |
请求参数
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| messages | LinkedList<BotMessage> | 是 | - | 消息列表 |
| model | String | 否 | - | 模型名称 |
| temperature | float | 否 | 0.95 | 温度参数,0-1 |
| top_p | float | 否 | 0.7 | Top P采样 |
| conversationId | String | 否 | - | 会话ID |
| containerId | List<String> | 否 | - | 知识库容器ID列表 |
| user | String | 否 | - | 用户标识 |
BotMessage结构:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| role | String | 是 | 角色类型 |
| content | Object | 否 | 消息内容 |
| reasoningContent | String | 否 | 推理内容 |
RequestBody示例
{
"messages": [
{
"role": "user",
"content": "你好,请介绍一下自己"
}
],
"model": "glm-4",
"temperature": 0.95,
"top_p": 0.7,
"conversationId": "conv_001",
"containerId": ["container_001"],
"user": "user_001"
}
响应示例
SSE流式或JSON响应:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "glm-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!我是智能助手,很高兴为您服务。"
},
"finish_reason": "stop"
}
]
}
请求示例
curl -X POST "${domain}/openapi/community/v1/chat/completions" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4",
"messages": [
{"role": "user", "content": "你好,请介绍一下自己"}
],
"containerId": ["container_001"],
"temperature": 0.95,
"top_p": 0.7
}'
应用面板信息
接口地址
GET /openapi/store/api/v1/dashboard
请求方法
GET
权限要求
app_dashboard READ
接口描述
获取应用面板配置信息。
请求Header
| Header名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | String | 是 | 认证Token |
请求参数
无
响应示例
{
"code": 8200,
"message": "操作成功",
"data": {
"id": 1,
"sort": 1,
"tenantId": "0",
"code": "app_001",
"title": "智能客服",
"description": "智能客服应用",
"logoImage": "https://cdn.example.com/logo.png",
"appUrl": "https://app.example.com/app_001"
}
}
请求示例
curl -X GET "${domain}/openapi/store/api/v1/dashboard" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json"
按AppID查询应用
接口地址
GET /openapi/store/api/v1/queryByAppId
请求方法
GET
权限要求
app_info READ
接口描述
根据AppID查询应用信息。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| appid | String | 是 | 应用ID(注意:参数名为小写appid) |
响应示例
{
"code": 8200,
"message": "操作成功",
"data": {
"appId": "app_001",
"name": "智能客服",
"description": "智能客服应用",
"icon": "https://cdn.example.com/icon.png",
"status": "published",
"config": {
"llmModel": "glm-4",
"llmTemperature": 0.7
}
}
}
请求示例
curl -X GET "${domain}/openapi/store/api/v1/queryByAppId?appid=app_001" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json"
应用商店列表
接口地址
GET /openapi/store/api/v1/store/list
请求方法
GET
权限要求
app_dashboard READ
接口描述
分页查询应用市场列表。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pageNo | Integer | 是 | 当前页码,默认1 |
| pageSize | Integer | 是 | 页码大小,默认10 |
| name | String | 否 | 应用名称(模糊查询) |
响应示例
{
"code": 8200,
"message": "操作成功",
"data": [
{
"id": 1,
"appid": "app_001",
"role": "assistant",
"category": "客服",
"icon": "https://cdn.example.com/icon.png",
"name": "智能客服",
"description": "智能客服应用",
"accessToken": "token_xxx",
"appUrl": "https://app.example.com/app_001",
"tag": "AI,客服",
"creator": "admin",
"createTime": "2024-01-01 10:00:00",
"modifier": "admin",
"modifierTime": "2024-01-01 10:00:00",
"sort": 1
}
],
"total": 1,
"totalPage": 1,
"pageNo": 1,
"pageSize": 10
}
请求示例
curl -X GET "${domain}/openapi/store/api/v1/store/list?pageNo=1&pageSize=10&name=客服" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json"
提交面板反馈
接口地址
POST /openapi/store/feedback/api/v1/add
请求方法
POST
权限要求
app_chat_feedback WRITE
接口描述
提交应用面板反馈。
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| conversationId | String | 是 | 会话ID |
| model | String | 否 | 模型名称,默认glm-3-turbo |
| question | String | 是 | 问题内容 |
| answer | String | 是 | 回答内容 |
| remark | String | 否 | 备注信息 |
| type | String | 是 | 反馈类型(like/tap/other) |
| tag | String | 否 | 标签 |
| messageId | String | 否 | 消息ID |
| appid | String | 否 | 应用ID |
RequestBody示例
{
"conversationId": "conv_001",
"model": "glm-3-turbo",
"question": "什么是知识库?",
"answer": "知识库是用于存储和管理知识的系统...",
"remark": "",
"type": "like",
"tag": "",
"messageId": "msg_001",
"appid": "app_001"
}
响应示例
{
"code": 8200,
"message": "提交成功",
"data": "feedback_001"
}
请求示例
curl -X POST "${domain}/openapi/store/feedback/api/v1/add" \
-H "Authorization: Bearer sk_xxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"conversationId": "conv_001",
"question": "什么是知识库?",
"answer": "知识库是用于存储和管理知识的系统...",
"type": "like",
"appid": "app_001"
}'
- Chat Completion V1
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求Header
- 请求参数
- RequestBody示例
- 响应示例
- 请求示例
- 查询可用模型列表
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求参数
- 响应示例
- 请求示例
- Chat OpenAI兼容接口
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求Header
- 请求参数
- RequestBody示例
- 响应示例
- 请求示例
- 应用面板信息
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求Header
- 请求参数
- 响应示例
- 请求示例
- 按AppID查询应用
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求参数
- 响应示例
- 请求示例
- 应用商店列表
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求参数
- 响应示例
- 请求示例
- 提交面板反馈
- 接口地址
- 请求方法
- 权限要求
- 接口描述
- 请求参数
- RequestBody示例
- 响应示例
- 请求示例