Skip to main content
POST
Train Index with Documents

Train Index with Documents

Train an index by uploading documents (files) or providing text inputs.

Endpoint

Description

Train an index by uploading documents (files) or providing text inputs. This endpoint supports multiple file formats and can process up to 20 files at once.

Supported File Formats

  • TXT
  • PDF
  • DOCX
  • DOC
  • JSON
  • CSV
  • XLS
  • XLSX

Authentication

Required: API Key

Path Parameters

Request Body

This endpoint accepts multipart/form-data format.

Parameters

Text Input Format

When using text_inputs, provide a JSON string array with objects containing:

Request Examples

Upload Files (Multipart Form Data)

JavaScript/Node.js

Python

Using Text Inputs

Response

Success Response (200)

Response Fields

Results Object

Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found

413 Payload Too Large

500 Internal Server Error

Notes

  • Maximum 20 files per request
  • Maximum 50MB per file
  • Files can be uploaded as multipart/form-data
  • Text inputs can be provided as a JSON string array
  • Documents are automatically chunked and vectorized for semantic search
  • The index must exist before training
  • Training results show how many documents were successfully indexed

Authorizations

Authorization
string
header
required

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

Path Parameters

indexName
string
required

Name of the index to train

Example:

"my-knowledge-base"

Body

multipart/form-data
files
file[]

Document files to upload (up to 20 files, 50MB each). Supported formats: TXT, PDF, DOCX, DOC, JSON, CSV, XLS, XLSX

Maximum array length: 20
text_inputs
string

JSON string array of text inputs. Each item should have:

  • name: string (filename)
  • type: string (MIME type, e.g., "text/plain")
  • content: string (text content)
  • size: number (content length in bytes)
Example:

"[{\"name\":\"doc1.txt\",\"type\":\"text/plain\",\"content\":\"Document content here\",\"size\":20}]"

Response

Index trained successfully

success
boolean
Example:

true

message
string
Example:

"Index trained successfully"

request_id
string<uuid>
Example:

"550e8400-e29b-41d4-a716-446655440000"

results
object