Request

Content-Type: multipart/form-data

The POST request should be a multipart form request containing the file to be uploaded.

Query Parameters

NameTypeRequiredDescription
chunk_sizeintegerNoThe chunk size (in tokens) applied when splitting the document
chunk_overlapintegerNoThe chunk overlap (in tokens) applied when splitting the document

Authentication

Before making requests to the AI Tutor RAG API, you need to obtain your API key from your dashboard.

Example Request

const formData = new FormData();
formData.append("file", files[0]); // Accepts PDF (.pdf) or text (.txt) files

const response = await fetch("https://rag-api-llm.up.railway.app/upload_file", {
  method: "POST",
  headers: {
    "authorization": apiKey,
  },
  body: formData,
});

Response

{
  "success": true,
  "message": "PDF file processed successfully",
  "file_id": "4db6b5d7-b199-4bfd-9914-6991cb4ba3b6",
  "file_name": "elon_musk.txt",
  "chunks": 2,
  "chunk_size": 1000,
  "chunk_overlap": 200
}

File Requirements Requirement Description File Types PDF (.pdf) or text (.txt) files only Maximum Size 10MB

Download CSV

Error Responses

{
  "success": false,
  "error": {
    "message": "Invalid file type. Only PDF and TXT files are supported",
    "code": "invalid_file_type"
  }
}

{
  "success": false,
  "error": {
    "message": "File size exceeds maximum limit of 10MB",
    "code": "file_too_large"
  }
}




{
  "success": false,
  "error": {
    "message": "Invalid API key provided",
    "code": "unauthorized"
  }
}