Skip to main content
from gravixlayer import GravixLayer

client = GravixLayer()
runtime = client.runtime.create(template="python-3.12-base-small")

client.runtime.write_file(
    runtime.runtime_id,
    path="/workspace/hello.txt",
    content="Hello from Gravix Layer\n",
)

# Read it back
result = client.runtime.read_file(runtime.runtime_id, path="/workspace/hello.txt")
print(result.content)

client.runtime.kill(runtime.runtime_id)

Parameters

ParameterTypeRequiredDescription
runtime_idstringYesRuntime identifier
pathstringYesDestination file path
contentstringYesFile content

Response

FieldTypeDescription
messagestringConfirmation message
pathstringWritten file path
bytes_writtenintegerNumber of bytes written

Batch Write

Write multiple files in a single call:
from gravixlayer import GravixLayer, WriteEntry

client = GravixLayer()
runtime = client.runtime.create(template="python-3.12-base-small")

result = client.runtime.write_files(
    runtime.runtime_id,
    entries=[
        WriteEntry(path="/workspace/a.txt", data="File A\n"),
        WriteEntry(path="/workspace/b.txt", data="File B\n"),
    ],
)

for f in result.files:
    print(f.path, f.size)

client.runtime.kill(runtime.runtime_id)