Brain
Ingest a document
Ingests a document as multipart (file part) or JSON with exactly one of text, url or file_base64. Ingest is size-scaled: 0.1 credits plus 0.0002 credits per KB of content, capped at 10 credits per document. A failed ingest is not charged.
POST
/
v1
/
brain
/
documents
Ingest a document
curl --request POST \
--url https://api.usenaive.ai/v1/brain/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"url": "<string>",
"file_base64": "<string>",
"filename": "<string>",
"content_type": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "<string>"
}
'import requests
url = "https://api.usenaive.ai/v1/brain/documents"
payload = {
"text": "<string>",
"url": "<string>",
"file_base64": "<string>",
"filename": "<string>",
"content_type": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
url: '<string>',
file_base64: '<string>',
filename: '<string>',
content_type: '<string>',
knowledge_base_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
source: '<string>'
})
};
fetch('https://api.usenaive.ai/v1/brain/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usenaive.ai/v1/brain/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'url' => '<string>',
'file_base64' => '<string>',
'filename' => '<string>',
'content_type' => '<string>',
'knowledge_base_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'source' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usenaive.ai/v1/brain/documents"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usenaive.ai/v1/brain/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usenaive.ai/v1/brain/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"knowledge_base_id": "<string>",
"filename": "<string>",
"source": "<string>",
"source_url": "<string>",
"status": "<string>",
"bytes": 123,
"created_at": "<string>",
"updated_at": "<string>"
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}Authorizations
Workspace API key. Create one via the dashboard or POST /v1/auth/keys.
Body
application/jsonmultipart/form-data
Raw text to ingest.
URL to fetch and ingest.
Base64-encoded file bytes.
Display filename or title.
MIME type for file_base64.
Target knowledge base.
Provenance label; defaults to api.
Maximum string length:
120⌘I
Ingest a document
curl --request POST \
--url https://api.usenaive.ai/v1/brain/documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"url": "<string>",
"file_base64": "<string>",
"filename": "<string>",
"content_type": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "<string>"
}
'import requests
url = "https://api.usenaive.ai/v1/brain/documents"
payload = {
"text": "<string>",
"url": "<string>",
"file_base64": "<string>",
"filename": "<string>",
"content_type": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"source": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: '<string>',
url: '<string>',
file_base64: '<string>',
filename: '<string>',
content_type: '<string>',
knowledge_base_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
source: '<string>'
})
};
fetch('https://api.usenaive.ai/v1/brain/documents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usenaive.ai/v1/brain/documents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'url' => '<string>',
'file_base64' => '<string>',
'filename' => '<string>',
'content_type' => '<string>',
'knowledge_base_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'source' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usenaive.ai/v1/brain/documents"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usenaive.ai/v1/brain/documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usenaive.ai/v1/brain/documents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"url\": \"<string>\",\n \"file_base64\": \"<string>\",\n \"filename\": \"<string>\",\n \"content_type\": \"<string>\",\n \"knowledge_base_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"source\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"knowledge_base_id": "<string>",
"filename": "<string>",
"source": "<string>",
"source_url": "<string>",
"status": "<string>",
"bytes": 123,
"created_at": "<string>",
"updated_at": "<string>"
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}{
"error": {
"message": "<string>",
"hint": "<string>",
"reason": "<string>"
}
}