Upload Document
Upload one or more documents to the RAG knowledge base. The service will save the files, split the text based on the parameters, and write them into the vector collection.
Try It
POST
/documents/uploadhttps://api-platform.ope.aiAuthentication
Uses Bearer Token authentication.
- Header:
Authorization: Bearer <token> - Example:
Authorization: Bearer sk-xxxxxx
Request Body (multipart/form-data)
| Field | Type | Required | Description | Default / Range |
|---|---|---|---|---|
model | string | Yes | The name of the embedding model used for document vectorization | e.g. bge-m3 |
files | file[] | Yes | The document files to upload. Supports multi-file upload under the same field name. | - |
chunk_size | integer | No | Document chunk size | Default 500 |
chunk_overlap | integer | No | The number of overlapping characters between adjacent chunks to maintain context continuity | Default 50 |
separators | string | No | Custom separators | Default splitting strategy |
Default Limits
| Limit Item | Default Limit | Description |
|---|---|---|
| Document Count | Max 100 documents per account | Includes documents currently retained in the knowledge base |
| Total Document Size | Max 200 MB cumulative size per account | When exceeding the limit, you need to delete some documents, compress/split documents, or apply for a higher quota |
For higher document counts, larger files, or dedicated knowledge base solutions, please contact us.
Request Examples
- cURL
- JavaScript
curl -X POST "https://api-platform.ope.ai/documents/upload" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-F "model=bge-m3" \
-F "chunk_size=500" \
-F "chunk_overlap=50" \
-F "files=@./handbook.pdf" \
-F "files=@./faq.docx"
const form = new FormData();
form.append("model", "bge-m3");
form.append("chunk_size", "500");
form.append("chunk_overlap", "50");
form.append("files", fileInput.files[0]);
const res = await fetch("https://api-platform.ope.ai/documents/upload", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OPEAI_API_KEY}`,
},
body: form,
});
console.log(await res.json());
Response Example
{
"status": "success",
"uploaded": [
{
"doc_id": "doc_1",
"filename": "handbook.pdf",
"status": "success"
}
]
}
Error Responses
| Status Code | Scenario | Description |
|---|---|---|
401 | Authentication failed | API Key is missing, invalid, or has insufficient permissions |
422 | Validation failed | Missing files/model, or form field format is incorrect |
500 | Upload processing failed | Failed to save file, split text, write to vector collection, or perform database operations |