Upload Text
This endpoint is used to directly upload text content to Supavec. You can either provide raw text that will be automatically chunked, or provide pre-chunked segments.
Request Body
- Name
contents
- Type
- string
- Description
Option A: Raw text content to upload and chunk automatically. Minimum length:
5
characters. Cannot be used together withsegments
.
- Name
segments
- Type
- array
- Description
Option B: Pre-chunked segments to upload directly. Each segment must contain:
content
(string, required): The text content of the segment (minimum 1 character)metadata
(object, optional): Additional metadata for the segment
Cannot be used together with
contents
.
- Name
name
- Type
- string
- Description
The name of the content. Defaults to
"Untitled Document"
if not provided.
- Name
chunk_size
- Type
- integer
- Description
The chunk size (in tokens) applied when splitting the document. Only used when
contents
is provided. Must be a positive number.
- Name
chunk_overlap
- Type
- integer
- Description
The chunk overlap (in tokens) applied when splitting the document. Only used when
contents
is provided. Must be a positive number and less thanchunk_size
.
Important: You must provide either contents
(for raw text) OR segments
(for pre-chunked content), but not both. If using contents
, ensure that chunk_overlap
is less than chunk_size
.
Before you can make requests to the Supavec API, you will need to grab your API key from your dashboard.
JavaScript (Raw Text)
const res = await fetch("https://api.supavec.com/upload_text", {
method: "POST",
headers: {
"Content-Type": "application/json",
authorization: apiKey,
},
body: JSON.stringify({
name: "My Document",
contents: "This is my text content...",
chunk_size: 1000,
chunk_overlap: 100
}),
});
JavaScript (Pre-chunked Segments)
const res = await fetch("https://api.supavec.com/upload_text", {
method: "POST",
headers: {
"Content-Type": "application/json",
authorization: apiKey,
},
body: JSON.stringify({
name: "My Document",
segments: [
{
content: "First chunk of content...",
metadata: { section: "intro" }
},
{
content: "Second chunk of content...",
metadata: { section: "body" }
}
]
}),
});
Response
{
"success": true,
"message": "Text uploaded and processed successfully",
"file_id": "939b2cd7-56d5-4c44-b491-14bfc202e9a0"
}