Files
Download a session file
Download a file the agent or the user attached to a session.
GET
/
api
/
v2
/
files
/
{file_id}
from hai_agents import Client
client = Client()
data = b"".join(client.session_files.download_file(file_id))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const file = await client.sessionFiles.downloadFile({ fileId });
const data = await file.arrayBuffer();
curl -L https://agp.eu.hcompany.ai/api/v2/files/$FILE_ID \
-H "Authorization: Bearer $HAI_API_KEY" \
-o report.pdf
When a file is attached to a session, the session gets an
Plus the common errors.
AttachmentEvent. Its data.file_id downloads that file. Downloads go through a presigned S3 URL.
Path parameters
Response
302 redirect to the presigned URL. SDK clients follow it and receive the raw bytes. With cURL, pass -L.
from hai_agents import Client
client = Client()
data = b"".join(client.session_files.download_file(file_id))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const file = await client.sessionFiles.downloadFile({ fileId });
const data = await file.arrayBuffer();
curl -L https://agp.eu.hcompany.ai/api/v2/files/$FILE_ID \
-H "Authorization: Bearer $HAI_API_KEY" \
-o report.pdf
Errors
| Status | Cause |
|---|---|
404 | File not found. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
data = b"".join(client.session_files.download_file(file_id))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const file = await client.sessionFiles.downloadFile({ fileId });
const data = await file.arrayBuffer();
curl -L https://agp.eu.hcompany.ai/api/v2/files/$FILE_ID \
-H "Authorization: Bearer $HAI_API_KEY" \
-o report.pdf