cURL
curl -X POST https://reygrid.com/api/v1/agents/{AgentId}/sources/files \
-H "Authorization: Bearer $REYGRID_API_KEY" \
-F "file=@handbook.pdf"from reygrid import ReyGrid
client = ReyGrid(api_key="YOUR_API_KEY")
# A path, bytes (with filename=...) or an open binary file
source = client.upload_file("{AgentId}", "handbook.pdf").source
print(source.id, source.size)import { ReyGrid } from "reygrid";
const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });
import { openAsBlob } from "node:fs";
const { source } = await client.uploadFile(
"{AgentId}",
await openAsBlob("handbook.pdf"),
"handbook.pdf",
);
console.log(source.id, source.size);{
"success": true,
"source": {
"id": "661a6da1-181f-43ac-9516-9847b9dd663b",
"type": "file",
"title": "handbook.pdf",
"size": 482113
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>",
"list": [
{}
]
},
"output": {},
"usage": {
"credits": 123
}
}{
"error": "Unauthorized",
"code": "AUTH_REQUIRED"
}{
"success": false,
"error": {
"code": "PLAN_LIMIT_REACHED",
"message": "You need to upgrade your plan"
}
}{
"success": false,
"error": {
"code": "SOURCE_NOT_FOUND",
"message": "This source does not exist"
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>",
"list": [
{}
]
},
"output": {},
"usage": {
"credits": 123
}
}Knowledge
Upload a file
Uploads a PDF, DOC, DOCX or TXT file (as large as the agent’s remaining storage). The file is split into chunks and indexed before the response is returned.
POST
/
agents
/
{agentId}
/
sources
/
files
cURL
curl -X POST https://reygrid.com/api/v1/agents/{AgentId}/sources/files \
-H "Authorization: Bearer $REYGRID_API_KEY" \
-F "file=@handbook.pdf"from reygrid import ReyGrid
client = ReyGrid(api_key="YOUR_API_KEY")
# A path, bytes (with filename=...) or an open binary file
source = client.upload_file("{AgentId}", "handbook.pdf").source
print(source.id, source.size)import { ReyGrid } from "reygrid";
const client = new ReyGrid({ apiKey: "YOUR_API_KEY" });
import { openAsBlob } from "node:fs";
const { source } = await client.uploadFile(
"{AgentId}",
await openAsBlob("handbook.pdf"),
"handbook.pdf",
);
console.log(source.id, source.size);{
"success": true,
"source": {
"id": "661a6da1-181f-43ac-9516-9847b9dd663b",
"type": "file",
"title": "handbook.pdf",
"size": 482113
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>",
"list": [
{}
]
},
"output": {},
"usage": {
"credits": 123
}
}{
"error": "Unauthorized",
"code": "AUTH_REQUIRED"
}{
"success": false,
"error": {
"code": "PLAN_LIMIT_REACHED",
"message": "You need to upgrade your plan"
}
}{
"success": false,
"error": {
"code": "SOURCE_NOT_FOUND",
"message": "This source does not exist"
}
}{
"success": true,
"error": {
"code": "<string>",
"message": "<string>",
"list": [
{}
]
},
"output": {},
"usage": {
"credits": 123
}
}