Skip to main content

Install the SDK

pip install gravixlayer

Run Your First Agent Runtime

Create a runtime, execute Python code, and clean up — in four lines.
from gravixlayer import GravixLayer

client = GravixLayer()

# Create an agent runtime
runtime = client.runtime.create(template="python-3.12-base-small")
print(f"Runtime: {runtime.runtime_id} ({runtime.status})")

# Run Python code
result = client.runtime.run_code(runtime.runtime_id, code="print('Hello from GravixLayer!')")
print(result.text)  # Hello from GravixLayer!

# Terminate the runtime
client.runtime.kill(runtime.runtime_id)

Run a Terminal Command

from gravixlayer import GravixLayer

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

# Run a shell command
cmd = client.runtime.run_cmd(runtime.runtime_id, command="python", args=["--version"])
print(cmd.stdout)  # Python 3.12.x

client.runtime.kill(runtime.runtime_id)

Write and Read Files

from gravixlayer import GravixLayer

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

# Write a file
client.runtime.write_file(runtime.runtime_id, path="/workspace/hello.txt", content="Hello World\n")

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

client.runtime.kill(runtime.runtime_id)

What’s Next

Code Execution

Run Python and JavaScript

Terminal

Shell commands and package installs

Custom Templates

Build your own runtime environments

Access Runtime

SSH or web terminal access