Ingest File
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/ingest.file \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"filename": "<string>",
"uri": "<string>",
"content_b64": "<string>",
"mode": "<string>",
"agent": "<string>",
"collection": "<string>",
"title": "<string>",
"excerpt_chars": 123,
"max_chars": 123,
"subject": "<string>",
"metadata": {}
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/ingest.file"
payload = {
"filename": "<string>",
"uri": "<string>",
"content_b64": "<string>",
"mode": "<string>",
"agent": "<string>",
"collection": "<string>",
"title": "<string>",
"excerpt_chars": 123,
"max_chars": 123,
"subject": "<string>",
"metadata": {}
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
filename: '<string>',
uri: '<string>',
content_b64: '<string>',
mode: '<string>',
agent: '<string>',
collection: '<string>',
title: '<string>',
excerpt_chars: 123,
max_chars: 123,
subject: '<string>',
metadata: {}
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/ingest.file', 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://composer.personal.ai/lab/api/v1/op/ingest.file",
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([
'filename' => '<string>',
'uri' => '<string>',
'content_b64' => '<string>',
'mode' => '<string>',
'agent' => '<string>',
'collection' => '<string>',
'title' => '<string>',
'excerpt_chars' => 123,
'max_chars' => 123,
'subject' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/ingest.file"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/ingest.file")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/ingest.file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{}
],
"chars": 123,
"excerpt": "<string>",
"excerpt_truncated": true,
"content": "<string>",
"truncated": true
}Knowledge
Ingest File
Add a document to an assistant’s knowledge, or read it once
POST
/
lab
/
api
/
v1
/
op
/
ingest.file
Ingest File
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/ingest.file \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"filename": "<string>",
"uri": "<string>",
"content_b64": "<string>",
"mode": "<string>",
"agent": "<string>",
"collection": "<string>",
"title": "<string>",
"excerpt_chars": 123,
"max_chars": 123,
"subject": "<string>",
"metadata": {}
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/ingest.file"
payload = {
"filename": "<string>",
"uri": "<string>",
"content_b64": "<string>",
"mode": "<string>",
"agent": "<string>",
"collection": "<string>",
"title": "<string>",
"excerpt_chars": 123,
"max_chars": 123,
"subject": "<string>",
"metadata": {}
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
filename: '<string>',
uri: '<string>',
content_b64: '<string>',
mode: '<string>',
agent: '<string>',
collection: '<string>',
title: '<string>',
excerpt_chars: 123,
max_chars: 123,
subject: '<string>',
metadata: {}
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/ingest.file', 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://composer.personal.ai/lab/api/v1/op/ingest.file",
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([
'filename' => '<string>',
'uri' => '<string>',
'content_b64' => '<string>',
'mode' => '<string>',
'agent' => '<string>',
'collection' => '<string>',
'title' => '<string>',
'excerpt_chars' => 123,
'max_chars' => 123,
'subject' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/ingest.file"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/ingest.file")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/ingest.file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"filename\": \"<string>\",\n \"uri\": \"<string>\",\n \"content_b64\": \"<string>\",\n \"mode\": \"<string>\",\n \"agent\": \"<string>\",\n \"collection\": \"<string>\",\n \"title\": \"<string>\",\n \"excerpt_chars\": 123,\n \"max_chars\": 123,\n \"subject\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"documents": [
{}
],
"chars": 123,
"excerpt": "<string>",
"excerpt_truncated": true,
"content": "<string>",
"truncated": true
}Overview
Parses a file and either saves it to knowledge (deep, the default) so the assistant can recall it later, or returns its text without saving anything (quick).
Supported formats: txt, md, html, pdf, docx, pptx, eml, csv and xlsx. Send the file inline as base64 (up to about 24 MB), or upload it first and pass its uri.
Changes data, so it needs a key that isn’t read-only.
ingest.file.
Authorization
Headers
Body
The
object_uri from Upload a File. Send this or content_b64.Example
"uri": "<object_uri from Upload a File>"
deep (default) saves it to knowledge. quick returns the text and saves nothing.Example
"mode": "deep"
Deep mode: also return up to this many characters of the text as
excerpt, to pass straight to Chat as an attachment.Example
"excerpt_chars": 4000
Example Request
{
"filename": "menu.pdf",
"uri": "<object_uri from Upload a File>",
"agent": "my-assistant",
"title": "Autumn menu",
"mode": "deep",
"excerpt_chars": 4000
}
Response
Example Success Response
{
"documents": [
{
"document_id": "c41d2e7a-6b5f-4a3e-8d9c-0b1a2f3e4d5c",
"kind": "prose",
"chunks": 6
}
],
"kind": "prose",
"parse_ms": 412,
"chars": 18240,
"excerpt": "Autumn menu. Pumpkin soup 6.50 ...",
"excerpt_truncated": true
}
Example cURL
cURL
curl --request POST 'https://composer.personal.ai/lab/api/v1/op/ingest.file' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{"filename": "menu.pdf", "uri": "<object_uri from Upload a File>", "agent": "my-assistant", "title": "Autumn menu", "mode": "deep", "excerpt_chars": 4000}'
Error Codes
| Code | Description |
|---|---|
| 400 | The body doesn’t match the fields above, or the operation failed. The response body says why. |
| 401 | Missing or invalid API key |
| 403 | This key isn’t allowed to call this operation (for example, a read-only key) |