Skip to main content
A template is a reusable filesystem image used to boot runtimes (sandboxes). Gravix Layer ships three system base templates, and you can build your own from a public Docker image or a Dockerfile. POST /v1/agents/runtime

Base templates

These are the foundational images for coding agents, code execution, and shell work. All three share the same toolchain; they differ only in CPU, memory, and disk.

What’s included

Full definition: base.Dockerfile in the Python SDK examples.

Users and layout

Python is managed by uv, not apt python3. The seeded workspace venv is on PATH (python / pip resolve there). Prefer pip install or uv pip install into /workspace/.venv.

Which size to pick

Agent templates (Claude Code / Codex)

Gravix Layer provides platform agent templates with the coding CLI already installed. Use them by name when creating a runtime — for example --template claude / template="claude". Building from the Dockerfile yourself is optional (custom packages, baked CLAUDE.md, private variants). Prefer 8 GB+ disk if you do build a custom image. Sandboxes deny egress by default. For the agent to call the model API:
  1. Create an Identity provider secret — ANTHROPIC_API_KEY for Claude, OPENAI_API_KEY for Codex — and attach it when creating the runtime.
  2. Create a network policy allowlist that includes the vendor API hosts (at minimum api.anthropic.com / api.openai.com on TCP 443; add auth and package-registry hosts as needed) and attach it to the runtime.
Step-by-step Claude Code usage: Claude Code on Gravix Layer.

Build a custom template

Build a template when you need packages, files, or a different base image baked in before the runtime boots. To save the state of a runtime that is already running, use a snapshot instead. You can build from:
  1. A public Docker image (from_image) plus SDK build steps, or
  2. A Dockerfile string (dockerfile) for full control of the image layers
The call blocks until the template is ready when you use build_and_wait (raise timeout_secs for large images). POST /v1/agents/template/build

From a Docker image

From a Dockerfile

Pass the Dockerfile contents directly. Put system packages and language installs in the Dockerfile; you still set start_cmd / ready_cmd on the builder so Gravix can launch and verify the app during the snapshot phase.
Set disk large enough for the image layers plus packages you install during the build. If the build fails with a disk check error, increase .disk(...).

Supported vs not supported

Gravix exports the Docker filesystem into the runtime image. Some Dockerfile / image settings are applied; others are ignored so platform defaults stay in control.

Supported

Not supported (silently ignored)

These may appear in a Dockerfile or image config. Gravix builds anyway and uses platform defaults instead — the build does not fail because of them. Platform-owned env keys from the image are also skipped when merging: PATH, HOME, HOSTNAME, SHELL, USER, LOGNAME.
If your Dockerfile relies on CMD or ENTRYPOINT to start a server, set .start_cmd(...) (and usually .ready_cmd(...)) on TemplateBuilder, or start processes with run_cmd after create.

Not supported (will fail or is unavailable)

TemplateBuilder reference

Manage templates

GET /v1/agents/template · GET /v1/agents/template/:id · DELETE /v1/agents/template/:id

Build status

Prefer build_and_wait for a simple blocking workflow. It starts the build and polls until a terminal status.