Files
Download a session resource
Download a screenshot or file the session produced.
GET
/
api
/
v2
/
sessions
/
{id}
/
resources
/
{bucket}
/
{key}
from hai_agents import Client
client = Client()
data = b"".join(client.sessions.get_session_resource(session_id, "screenshots", "step-5.png"))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.getSessionResource({
id: sessionId,
bucket: "screenshots",
key: "step-5.png",
});
curl -L https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/resources/screenshots/step-5.png \
-H "Authorization: Bearer $HAI_API_KEY" \
-o screenshot.png
Behavior
Downloads go through a presigned S3 URL. Works without a key on shared sessions.Path parameters
string
required
The session ID.
string
required
The resource bucket, for example
screenshots or files.string
required
The resource key (path within the bucket).
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.sessions.get_session_resource(session_id, "screenshots", "step-5.png"))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.getSessionResource({
id: sessionId,
bucket: "screenshots",
key: "step-5.png",
});
curl -L https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/resources/screenshots/step-5.png \
-H "Authorization: Bearer $HAI_API_KEY" \
-o screenshot.png
Download a shared file
GET /api/v2/files/{file_id}
When the agent sends you a file, the session gets an AttachmentEvent. Its data.file_id downloads that file. Auth and the 302 work as above.
string
required
The
file_id from the file’s AttachmentEvent.curl -L https://agp.eu.hcompany.ai/api/v2/files/$FILE_ID \
-H "Authorization: Bearer $HAI_API_KEY" \
-o report.pdf
data = b"".join(client.session_files.download_file(file_id))
const file = await client.sessionFiles.downloadFile({ fileId });
const data = await file.arrayBuffer();
Errors
| Status | Cause |
|---|---|
404 | Session, resource, or file not found. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
data = b"".join(client.sessions.get_session_resource(session_id, "screenshots", "step-5.png"))
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
await client.sessions.getSessionResource({
id: sessionId,
bucket: "screenshots",
key: "step-5.png",
});
curl -L https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID/resources/screenshots/step-5.png \
-H "Authorization: Bearer $HAI_API_KEY" \
-o screenshot.png