Gravix Layer Python SDK — agent runtimes and templates (Alpha; API may evolve). See docs.gravixlayer.ai.
Project description
Gravix Layer Python SDK
Official Python client for Gravix Layer — create and manage cloud agent runtimes and templates for your workloads.
New to this SDK?
| Step | Action |
|---|---|
| 1 | Install: pip install gravixlayer |
| 2 | Set API key: export GRAVIXLAYER_API_KEY="your-api-key" (from the Gravix Layer console) |
| 3 | Run the quick start below, or open examples/ for runnable scripts (runtimes, templates) |
Docs: docs.gravixlayer.ai · Examples index: examples/README.md
Install
pip install gravixlayer
Configure
export GRAVIXLAYER_API_KEY="your-api-key"
export GRAVIXLAYER_CLOUD="azure" # default
export GRAVIXLAYER_REGION="eastus2" # default
Or pass options to the client:
from gravixlayer import GravixLayer
client = GravixLayer(
api_key="your-api-key",
base_url="https://api.gravixlayer.ai",
cloud="azure",
region="eastus2",
)
Quick start
from gravixlayer import GravixLayer
client = GravixLayer()
runtime = client.runtime.create(template="python-3.14-base-small")
result = client.runtime.run_code(
runtime.runtime_id,
code="print('Hello from Gravix Layer')",
)
print(result.text)
client.runtime.kill(runtime.runtime_id)
File operations
Use client.runtime.file with short names: read, write (JSON text write), delete, list, upload (multipart bytes), write_many (batch multipart), plus create_directory, get_info, set_permissions. File operations live only under file.* (not on client.runtime directly).
With a Runtime instance, use runtime.file — same methods, without passing runtime_id each time:
runtime = client.runtime.create(template="python-3.14-base-small")
runtime.file.write("/workspace/note.txt", "hello\n")
text = runtime.file.read("/workspace/out.txt").content
client.runtime.kill(runtime.runtime_id)
See examples/runtimes/07_file_operations.py for a full walkthrough.
Examples (runnable)
| Area | What you’ll learn |
|---|---|
| examples/runtimes/ | Create runtimes, run code & shell, files, metrics, SSH, context manager, Git — 16 scripts |
| examples/templates/ | Build custom templates (Docker image, Git, Dockerfile) — 6 scripts |
Start here: examples/README.md (task table + quick reference).
Performance note (connections and HTTP/2)
The client uses HTTP/1.1 by default for predictable latency on typical API usage.
- Warm the connection before creating many runtimes: call
client.warmup()once (or usewarmup_on_init=Truewhen constructing the client). That pays TCP, TLS, and protocol setup up front so the first real request is cheaper. - HTTP/2: pass
http2=Trueto theGravixLayerclient constructor if you want multiplexing over a single established connection after TLS (useful for high concurrency). Requires thehttpx[http2]extra (already declared by this package).
Sync:
from gravixlayer import GravixLayer
client = GravixLayer(http2=True)
client.warmup()
# or: GravixLayer(http2=True, warmup_on_init=True)
Async: pass http2=True to AsyncGravixLayer and call await client.warmup() before heavy traffic.
from gravixlayer import AsyncGravixLayer
async with AsyncGravixLayer(http2=True) as client:
await client.warmup()
Async
import asyncio
from gravixlayer import AsyncGravixLayer
async def main():
async with AsyncGravixLayer() as client:
runtime = await client.runtime.create(template="python-3.14-base-small")
await client.runtime.kill(runtime.runtime_id)
asyncio.run(main())
Development
For local development and CI, run the unit tests (HTTP mocked; no API key required):
pip install -e ".[test]"
pytest tests/unit_tests
Test layout (tests/unit_tests vs tests/integration_tests), integration runs, and markers are documented in tests/README.md so this file stays focused on SDK usage.
Documentation and support
- Examples: examples/README.md
- Documentation: docs.gravixlayer.ai
- Issues: GitHub Issues
Feedback: gravixlayer/gravixlayer-feedback — bugs, features, and product feedback.
License
Apache License 2.0 — see LICENSE.
Copyright 2026 Gravix Layer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gravixlayer-0.1.45.tar.gz.
File metadata
- Download URL: gravixlayer-0.1.45.tar.gz
- Upload date:
- Size: 115.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1993cb9ad28426c1eed5a7b3a8ce00b90febc62c3243a1380248d3ae37e0d5c8
|
|
| MD5 |
9b06bbdbc4f12f89f35045ff99c147c8
|
|
| BLAKE2b-256 |
9f07388b67ee060605f6c5c3482c74578d90f44467628053baf018960881ada9
|
File details
Details for the file gravixlayer-0.1.45-py3-none-any.whl.
File metadata
- Download URL: gravixlayer-0.1.45-py3-none-any.whl
- Upload date:
- Size: 83.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba419fd1acac80776c04d49b75528212733e88235eee193373e756e1a812787d
|
|
| MD5 |
fef32597c46f34e0539497df81956851
|
|
| BLAKE2b-256 |
138875c4e1ff8a10e4c747043b9b40e7054489ef2079e79d9e0ec2a18e07c2d4
|