Baidu 
Authentication 
Baidu Chat 
接口功能: 官方所有 chat 接口
Method & Path 
-  
POST {domain}/bp/ai/baidu/chat -  
POST {domain}/bp/server/user/{user_id}/ai/baidu/chat 
Request 
- content-type: "application/json"
 
| Parameters | Type | Required | Desc | 
|---|---|---|---|
| strategy | string | true | strategy | 
| module | string | true | must be chat | 
| chat_id | string | false | server save history | 
| model | string | true | chat model | 
| ... | ... | true | other Parameters | 
支持官方所有接口,只需在官方文档的请求参数添加 strategy 和对应的 model
比如官方模型 ERNIE-Bot 对应的 API 地址: https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions
则 model 填 completions
Request 
json
{
  "strategy": "baidu_chat",
  "module": "chat",
  "model": "completions",
  "data": {
    "messages": [
      {
        "role": "user",
        "content": "介绍一下你自己"
      }
    ]
  }
}Response 
- HTTP 状态码:200
 
json
{
  "chat_id": "CtEIULLHPXPDBMYLTH",
  "current_count": 1,
  "current_total_count": 8,
  "data": {
    "id": "as-v5xj7nyzut",
    "object": "chat.completion",
    "created": 1709601479,
    "result": "您好,我是文心一言,英文名是ERNIE Bot。我能够与人对话互动,回答问题,协助创作,高效便捷地帮助人们获取信息、知识和灵感。",
    "is_truncated": false,
    "need_clear_history": false,
    "finish_reason": "normal",
    "usage": {
      "prompt_tokens": 2,
      "completion_tokens": 33,
      "total_tokens": 35
    }
  }
}Baidu Chat Steam 
接口功能: 官方所有 chat stream 接口
Method & Path 
-  
POST {domain}/bp/ai/baidu/chat/stream -  
POST {domain}/bp/server/user/{user_id}/ai/baidu/chat/stream 
Request 
- content-type: "application/json"
 
| Parameters | Type | Required | Desc | 
|---|---|---|---|
| strategy | string | true | strategy | 
| module | string | true | must be chat | 
| model | string | true | chat model | 
| chat_id | string | false | server save history | 
| ... | ... | true | other Parameters | 
支持官方所有接口,只需在官方文档的请求参数添加 strategy 和对应的 model
比如官方模型 ERNIE-Bot 对应的 API 地址: https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions
则 model 填 completions
Request 
json
{
  "strategy": "baidu_chat",
  "chat_id": "CtEJZEQBEJCE3KEMQ4",
  "module": "chat",
  "model": "completions",
  "data": {
    "messages": [
      {
        "role": "user",
        "content": "介绍一下你自己"
      }
    ]
  }
}Response 
- HTTP 状态码:200
 
json
event: ai_chat_msg
data: {"chat_id":"CtEJZEQBEJCE3KEMQ4","content":"你好!","is_finish":false}
event: ai_chat_msg
data: {"chat_id":"CtEJZEQBEJCE3KEMQ4","content":"看起来你似乎想和我进行对话","is_finish":true}Baidu Image 
接口功能: 官方所有 chat 接口
Method & Path 
-  
POST {domain}/bp/ai/baidu/image -  
POST {domain}/bp/server/user/{user_id}/ai/baidu/image 
Request 
- content-type: "application/json"
 
| Parameters | Type | Required | Desc | 
|---|---|---|---|
| strategy | string | true | strategy | 
| module | string | true | must be image | 
| model | string | true | image model | 
| ... | ... | true | other Parameters | 
支持官方所有接口,只需在官方文档的请求参数添加 strategy 和对应的 model
比如官方模型 Stable-Diffusion-XL 对应的 API 地址: https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/text2image/sd_xl
则 model 填 sd_xl
Request 
json
{
  "strategy": "baidu_image",
  "module": "image",
  "model": "sd_xl",
  "data": {
    "prompt": "cat",
    "size": "1024x1024"
  }
}
```
### Response
- HTTP 状态码:200
```json
{
  "current_count": 1,
  "current_total_count": 4,
  "data": [
    "https://715x351k8o.debug-static.bytepowerapp.cn/ai/image_resp/2024-03-05/543662850823.jpg"
  ]
}