> ## Documentation Index
> Fetch the complete documentation index at: https://hub.hcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> H Platform has four products: the Agents API (managed computer-use agents, base URL https://agp.eu.hcompany.ai/api/v2 or https://agp.hcompany.ai/api/v2 for the US), the Models API (OpenAI-compatible Holo vision-language models at https://api.hcompany.ai/v1), HoloDesktop CLI (Holo on the user's own desktop), and HoloTab (a free no-code Chrome extension that runs Holo in the user's browser, with recordable routines and schedules).
> Authenticate with a bearer API key from the HAI_API_KEY environment variable. SDKs: `pip install hai-agents` (Python, `from hai_agents import Client`) and `npm install hai-agents` (TypeScript, `import { HaiAgentsClient } from "hai-agents"`). CLI: `hai`.
> Agents do work in a browser or on a desktop; describe the task as an imperative instruction. To run a task quickly, prefer the pre-built agent `h/web-surfer-flash`. Read results from the session's `latest_answer` after it reaches a terminal status.
> Sessions are the unit of work; wait for a terminal status (completed, failed, timed_out, interrupted) before reading the answer. Use webhooks or the `changes` long-poll endpoint to follow progress.

# Read file

> Download a file from a cloud browser's machine, base64-encoded.

Reads one file from the machine hosting a cloud browser and returns it base64-encoded, with its size and modification time. Pair it with [list files](/agents-api/sessions/list-files) to pull out what the agent downloaded.

**Returns** the file's `path`, `content_base64`, `size_bytes`, and `modified_at`.

<Note>
  `session_id` is the **browser session id** from the session's `RunnerSessionEvent`, not the agent session id. See [list files](/agents-api/sessions/list-files) for how to obtain it.
</Note>

Files are capped at 8 MiB; larger ones are rejected. Only `~/Downloads` is reachable.

***

## Path parameters

<ParamField path="session_id" type="string" required>
  The browser session id.
</ParamField>

***

## Request body

<ParamField body="path" type="string" required>
  File to read. Absolute, or relative to the browser's home (`~/Downloads/report.csv`).
</ParamField>

***

## Response

<ResponseField name="path" type="string">
  The file's resolved path.
</ResponseField>

<ResponseField name="content_base64" type="string">
  The file's bytes, base64-encoded.
</ResponseField>

<ResponseField name="size_bytes" type="integer">
  Size of the file in bytes.
</ResponseField>

<ResponseField name="modified_at" type="string">
  ISO 8601 modification time.
</ResponseField>

***

## Examples

<CodeGroup>
  ```bash cURL theme={"system"}
  curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions/$BROWSER_SESSION_ID/files/read_file \
    -H "Authorization: Bearer $HAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"path": "~/Downloads/invoice-2026-09.pdf"}' \
    | jq -r .content_base64 | base64 -d > invoice-2026-09.pdf
  ```

  ```python Python theme={"system"}
  import base64
  from hai_agents import Client

  client = Client()

  file = client.session_files.read_file(browser_session_id, path="~/Downloads/invoice-2026-09.pdf")
  with open("invoice-2026-09.pdf", "wb") as out:
      out.write(base64.b64decode(file.content_base64))
  ```

  ```typescript TypeScript theme={"system"}
  import { writeFileSync } from "node:fs";
  import { HaiAgentsClient } from "hai-agents";

  const client = new HaiAgentsClient();

  const file = await client.sessionFiles.readFile({
    sessionId: browserSessionId,
    path: "~/Downloads/invoice-2026-09.pdf",
  });
  writeFileSync("invoice-2026-09.pdf", Buffer.from(file.contentBase64, "base64"));
  ```
</CodeGroup>

```json Response theme={"system"}
{
  "path": "/home/hai/Downloads/invoice-2026-09.pdf",
  "content_base64": "JVBERi0xLjcKJc...",
  "size_bytes": 48213,
  "modified_at": "2026-09-15T09:41:12Z"
}
```
