Upload File
Last updated:2023-11-02

Upload File

Upload documents to the Bot Knowledge Base and execute embedding.

Note:

  • By default, it is sliced every 600 Tokens.
  • Only the upload result is returned, not the final embedding result. You can get the result through the "Query Doc Status" API.

Request Method

POST

Request URL

https://api.gptbots.ai/v1/bot/data/file/upload

Request Authentication

See Overview for authentication details.

Request

Request Example

curl -X POST https://api.gptbots.ai/v1/bot/data/file/upload \ -H 'Authorization: Bearer your_apikey' \ -H 'Content-Type: multipart/form-data' \ -F 'file=@/usr/test.txt'
          curl -X POST https://api.gptbots.ai/v1/bot/data/file/upload \
  -H 'Authorization: Bearer your_apikey' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@/usr/test.txt'

        
This code block in the floating window

Request Headers

Field Type Description
Authorization Bearer ${token} Use Authorization: Bearer ${token} for authentication. Get the key from the API Keys page as token.
Content-Type multipart/form-data Data type, set to multipart/form-data.

Request Body

ld Type Required Description
file byte[] Yes Document files, supporting pdf, doc, docx, md, txt formats.

Response

Response Example

{ "data_id": "65e18b26e121ab08cefb4a53", "data_name": "test.txt" }
          {
    "data_id": "65e18b26e121ab08cefb4a53",
    "data_name": "test.txt"
}

        
This code block in the floating window

Success Response

Field Type Description
id string Doc ID.
name string Doc name.

Failure Response

Field Type Description
code int Error code.
message string Error details.

Error Codes

Code Message
40000 Invalid parameter
40127 Developer authentication failed
20059 Bot deleted
40380 Unsupported data type
40381 File upload failed
40382 The file size exceeds the limit