Skip to main content

Gravix Layer Python SDK — agent runtimes and templates (Alpha; API may evolve). See docs.gravixlayer.ai.

Project description

Gravix Layer Python SDK

PyPI version Python 3.9+ License: Apache 2.0

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")

# Run Python code
result = runtime.run_code(code="print('Hello from Gravix Layer')")
print(result.text)

# Run a shell command
runtime.run_cmd(command="pip install pandas --quiet")
runtime.run_cmd(command="pip", args=["install", "pandas", "--quiet"])

runtime.kill()

File operations

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
runtime.kill()

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 use warmup_on_init=True when constructing the client). That pays TCP, TLS, and protocol setup up front so the first real request is cheaper.
  • HTTP/2: pass http2=True to the GravixLayer client constructor if you want multiplexing over a single established connection after TLS (useful for high concurrency). Requires the httpx[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

support@gravixlayer.ai

Feedback: gravixlayer/gravixlayer-feedback — bugs, features, and product feedback.

License

Apache License 2.0 — see LICENSE.
Copyright 2026 Gravix Layer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gravixlayer-0.1.52.tar.gz (133.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gravixlayer-0.1.52-py3-none-any.whl (97.6 kB view details)

Uploaded Python 3

File details

Details for the file gravixlayer-0.1.52.tar.gz.

File metadata

  • Download URL: gravixlayer-0.1.52.tar.gz
  • Upload date:
  • Size: 133.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gravixlayer-0.1.52.tar.gz
Algorithm Hash digest
SHA256 6d41283b512202999f3276f55e3bd176c739da96d719cd2fa2657be6f5649080
MD5 a3399aff2bb5d4b9ae0fe208b01a5bf9
BLAKE2b-256 cb3445eb2bcfa5001b1f88e6b50312a5d9c158ac3f6d2de54d8c97e6f8515f00

See more details on using hashes here.

File details

Details for the file gravixlayer-0.1.52-py3-none-any.whl.

File metadata

  • Download URL: gravixlayer-0.1.52-py3-none-any.whl
  • Upload date:
  • Size: 97.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gravixlayer-0.1.52-py3-none-any.whl
Algorithm Hash digest
SHA256 6e8d5f792b5ef1bf574c05984cc0cde6f6e21351a22382c5fe19b1d0135b6b06
MD5 5fb18bbb339af93dec86ea3370a23d40
BLAKE2b-256 9b0760c1a8850af12d485a1872a6899446176a4790f58005d4117116d3fea7b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page