百川智能
  1. 通用大模型
百川智能
  • 通用大模型
    • 接口说明
    • 同步接口
      POST
    • 同步请求知识库
      POST
    • 流式接口
      POST
  • 通用大模型(旧版)
    • 接口说明
    • 同步接口
      POST
    • 流式接口
      POST
  • 知识库
    • 创建知识库接口
      POST
    • 知识库检索接口
      GET
    • 修改知识库接口
      POST
    • 删除知识库接口
      DELETE
    • 知识库列表查询接口
      GET
    • 创建知识库文件接口
      POST
    • 知识库文件检索接口
      GET
    • 知识库文件删除接口
      DELETE
    • 知识库文件列表查询接口
      GET
  • 向量化模型
    • 单次请求
      POST
    • 批次请求
      POST
  • 文件管理
    • 文件列表查询
      GET
    • 文件上传接口
      POST
    • 文件删除接口
      DELETE
    • 文件检索接口
      POST
    • 文件下载接口
      GET
  • 财务相关
    • 发票
  1. 通用大模型

同步请求知识库

开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
/v1/chat/completions
在使用 API 接口前,请先在百川 API 开放平台完成实名认证、充值、创建 APIkey 等流程,如下图所示
Alt text
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://dev-cn.your-api-server.com/v1/chat/completions' \
--header 'Authorization: Bearer ${api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
              "model":"Baichuan2-Turbo",
              "messages":[
                  {
                      "role":"user",
                      "content":"张三毕业院校是哪里?"
                  }
              ],
              "temperature":0.4,
              "top_p":0.5,
              "top_k":10,
              "stream":false,
              "with_search_enhance": true,
              "knowledge_base":{
                  "ids":["kb-byQblaWnMEc0kVCb7OMzMQia","kb-ZGz9LBtgEKgxvFtrdKEyKSCS"]
              }
          }'
响应示例响应示例
                {
  "id": "chatcmpl-Mb65700CC3MOkhJ",
  "object": "chat.completion",
  "created": 1702351344,
  "model": "Baichuan2-Turbo",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "张三的毕业院校是xxx大学。"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1278,
    "completion_tokens": 10,
    "total_tokens": 1288
  },
  "knowledge_base": {
    "cites": [
      {
        "title": "【高级Java工程师】张三.pdf",
        "content": "在职时间\n所属行业\n公司名称\n担任职位\n2018.05--至今\nxxxxxxx",
        "file_id": "file-HdcrTddtCp2Nbo50uci5rADP"
      }
    ]
  }
}

              

请求参数

Header 参数
Content-Type
string 
必需
示例值:
application/json
Authorization
string 
必需
示例值:
Bearer ${api_key}
Body 参数application/json
model
string 
必需
使用的模型 ID,模型列表: Baichuan2-Turbo Baichuan2-Turbo-192k
messages
array [object {2}] 
必需
对话消息列表 (历史对话按从老到新顺序填入)
role
string 
必需
消息作者的角色,为以下其中之一 1. user 2. assistant
content
string 
消息内容
必需
temperature
number 
可选
取值范围: [.0f, 1.0f]。 多样性,越高,多样性越好, 缺省 0.3
top_p
number 
可选
取值范围: [.0f, 1.0f)。值越小,越容易出头部, 缺省 0.85
top_k
integer 
可选
取值范围: [0, 20]。搜索采样控制参数,越大,采样集大, 0 则不走 top_k 采样筛选策略,最大 20(超过 20 会被修正成 20),缺省 5
stream
boolean 
可选
是否使用流式接口,默认值为 false
with_search_enhance
boolean 
可选
True: 开启 web 搜索增强,搜索增强会产生额外的费用, 缺省 False
knowledge_base
object 
知识库信息
可选
ids
array[string]
可选
知识库 id 列表,当with_search_enhance 与 knowledge_base 同时被设置时默认使用知识库检索。
示例

返回响应

🟢200成功
application/json
Body
id
string 
必需
object
string 
必需
created
integer 
必需
model
string 
必需
choices
array [object {3}] 
必需
index
integer 
可选
message
object 
可选
finish_reason
string 
可选
usage
object 
必需
prompt_tokens
integer 
必需
completion_tokens
integer 
必需
total_tokens
integer 
必需
knowledge_base
object 
必需
cites
array [object {3}] 
必需
上一页
同步接口
下一页
流式接口
Built with