Overview
Agent runs can produce files such as CSV, JSON, JSONL, and reports in the sandbox. When code the model runs in thesandbox tool writes a file and delivers it with the share_file tool, the response output array includes a share_file item. The file content is not returned inline — retrieve it separately with the response files endpoints, using the response id.
Produce a file
Give the agent thesandbox tool and ask it to write a file. Here it generates a CSV of the latest AI news. Keep the resulting response.id — you use it to list and download the file.
For runs that take a while, submit with
background=true and poll before listing files. See Background mode.List a response’s files
GET /v1/responses/{id}/files
Use the response id from the run above to list the files it produced.
| Field | Type | Description |
|---|---|---|
id | string | File identifier, used to download; distinct from response id. |
filename | string | Name the sandbox gave the file. |
bytes | integer | File size in bytes. |
created_at | integer | Unix timestamp when created. |
object | string | Always file. |
Download a file
GET /v1/responses/{id}/files/{file_id}/content
Use the file id to download its content. The file id is distinct from the response id.
This endpoint returns raw file bytes, not JSON. The response includes a
Content-Type matching the file and a Content-Disposition: attachment header carrying the original filename.Full example
Create a run that writes a file, then list and download everything it produced.Python