POST /v1/agents/runtime/{runtime_id}/files/read
CLI and cURL examples assume
$RT (runtime ID) and GRAVIXLAYER_API_KEY are set:export GRAVIXLAYER_API_KEY="your-api-key"
export RT="<runtime-id>"
from gravixlayer import GravixLayer
client = GravixLayer() # defaults to cloud="aws", region="us-east-1"
sandbox = client.runtime.create() # defaults to template="base-small"
# Write a file first so we have something to read
sandbox.file.write("/workspace/output.txt", "hello from gravix\n")
result = sandbox.file.read("/workspace/output.txt")
print(result.content)
print(result.size) # File size in bytes
sandbox.kill()
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"
const sandbox = await client.runtime.create(); // defaults to template="base-small"
// Write a file first so we have something to read
await sandbox.file.write("/workspace/output.txt", "hello from gravix\n");
const result = await sandbox.file.read("/workspace/output.txt");
console.log(result.content);
console.log(result.size); // File size in bytes
await sandbox.kill();
gravixlayer runtime files cat "$RT" /workspace/output.txt
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/files/read" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "/workspace/output.txt"}'
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | File path to read |
Response
| Field | Type | Description |
|---|---|---|
content | string | File text content |
path | string | Resolved file path |
size | integer | File size in bytes |