在使用 API 接口前,请先在百川 API 开放平台完成实名认证、充值、创建 APIkey 等流程,如下图所示 

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"
      }
    ]
  }
}