withruntime
The official client for Runtime Cloud: Linux machines for AI agents and apps, each a
microVM with its own kernel, disk and network, created in milliseconds and billed for the CPU it uses and the memory
it holds. The client is generated from the API's OpenAPI description, so every product and every operation of
https://api.withruntime.com/v2 is here, typed.
Install
pip install withruntime
Python 3.9 or later. The one dependency is httpx; pip install withruntime[keypair] adds signing with a key pair.
Authentication
The client reads your API key from RUNTIME_API_KEY. Create a key at https://withruntime.com/account/keys and keep it
in a secret manager, never in source code or a URL. A key pair's rtsk_ secret also works: the client signs each
request with it and never sends it.
Quickstart
from withruntime import Sandbox
with Sandbox.create() as sbx:
sbx.files.write("/workspace/invoice.py", "print(sum([125, 250, 375]))\n")
result = sbx.exec("python3 /workspace/invoice.py")
print(result.exit_code, result.stdout) # 0 750
Leaving the with block deletes the sandbox. AsyncRuntime, AsyncSandbox and the other Async classes are the
same for asyncio, with async with and await.
Configuration
import os
from withruntime import Runtime
runtime = Runtime(
api_key=os.environ["RUNTIME_API_KEY"], # the default
project="prj_...", # default: RUNTIME_PROJECT
base_url="https://api.withruntime.com", # default: RUNTIME_API_URL
max_retries=3,
)
sbx = runtime.sandboxes.create(vcpu=4, memory_gb=8)
Products
| Class | Create one | What it is |
|---|---|---|
Sandbox |
Sandbox.create() |
A Linux machine with its own kernel, made in milliseconds, paused with its memory kept when idle and resumed where it was. |
FunctionMachine |
FunctionMachine.create() |
A machine that answers HTTP with a handler in /app/index.ts (export default { fetch(request) }, as Cloudflare Workers and Vercel take one) on port 8080, reached at its preview. |
App |
App.create() |
A machine that keeps a web app in /app running on port 8080 (its Procfile's web:, else npm start, else python3 app.py, as Render and Heroku start one), reached at its preview. |
Site |
Site.create() |
A machine that serves the static files in /site on port 8080 (as Netlify and Vercel serve a build's output), reached at its preview. |
CiMachine |
CiMachine.create() |
A machine that runs a repository's checks to their end (its run) with git, Docker, Node, Bun, Python and a compiler, and is stopped then. |
Browser |
Browser.create() |
A machine running headless Chromium, driven over the Chrome DevTools Protocol at its preview on port 9222: one WebSocket address for Playwright's connectOverCDP and Puppeteer's connect, as Browserbase gives one. |
Desktop |
Desktop.create() |
A machine running a Linux desktop with Chromium, for agents that use a computer: screenshot returns what its screen shows and act moves and clicks its mouse and types on its keyboard. |
Notebook |
Notebook.create() |
A machine running JupyterLab on port 8888 over /workspace, with NumPy, pandas and matplotlib, reached at its private preview. |
Workspace |
Workspace.create() |
A development environment: a machine running VS Code in the browser (code-server) on port 8080 over /workspace, reached at its private preview, as Codespaces and Gitpod give one. |
Container |
Container.create() |
A machine that runs one OCI image from any registry under Docker on its own network (start runtime-container <image>), the port it listens on reached at its preview, as Cloud Run and Fly Machines run one. |
Build |
Build.create() |
The machine an image's build runs on: Docker's own builder (BuildKit), its run runtime-image-build, deleted once its image is made. |
Job |
Job.create() |
A command run in a fresh machine, once or on a cron schedule in a timezone. |
Image |
Image.create() |
What a machine boots: a root filesystem, its environment and its start. |
Volume |
Volume.create() |
A disk that outlives the machines it is attached to. |
Domain |
Domain.create() |
Your own hostname serving a machine's port, with HTTPS. |
Every machine (each class above with files) has refresh, delete, pause, resume, exec, metrics, fork, snapshot, update, screenshot, act, run_code, spawn, files.read, files.write, files.remove, files.stat, files.list, files.download_folder, files.upload_folder, files.begin_folder_upload, files.write_folder_upload, files.commit_folder_upload, files.abort_folder_upload, files.mkdir, files.rename, files.link, files.revoke_links, processes.output, processes.write, processes.signal, processes.resize, processes.list, network.get, network.set.
Sandboxalso hasexec_stream,previews.create.Jobalso hasrun.Imagealso haslogs.Domainalso hasverify.
The API's other resources (keys, projects, roles, secrets, snapshots, webhooks, usage and more) are clients on the runtime object. The API reference lists every operation.
Errors
Every error the API returns is raised as a RuntimeApiError with code, message, status, request_id,
hint, param and retryable. Each error family has its own subclass, such as NotFoundError,
InvalidRequestError, RateLimitedError and CapacityUnavailableError:
from withruntime import NotFoundError
try:
runtime.sandboxes.get("sbx_missing")
except NotFoundError as err:
print(err.code, err.request_id)
Retries and idempotency
The client retries a rate-limited (429) or unavailable (503) answer, and a lost connection on a call that is safe to send again, up to max_retries times (default 3). Every write sends an Idempotency-Key header, generated when you do not pass idempotency_key, so a retry never runs a write twice.
Lists
A list call returns a page; iterating it yields every item across pages:
for s in runtime.sandboxes.list(state="running"):
print(s.id)
Versioning
The package follows Semantic Versioning: a minor or patch release never breaks code written
for an earlier release of the same major version. Each request sends the API version the client was generated for in
the Runtime-Version header. Every release is listed in CHANGELOG.md.
Resources
- Guides: https://withruntime.com/docs
- API reference: https://withruntime.com/docs/reference
- Pricing: https://withruntime.com/pricing
- Status: https://status.withruntime.com
- Support: support@withruntime.com
License
Apache-2.0
Metadata
Release files for withruntime 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| withruntime-1.1.0.tar.gz | 274.6 kB | With provenance | Details for withruntime-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| withruntime-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for withruntime-1.1.0-py3-none-any.whl |
Total release size: 589.6 kB
Release files / withruntime-1.1.0.tar.gz
| Download URL | withruntime-1.1.0.tar.gz |
|---|---|
| Size | 274.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5530edd390e1ede2b638e7c94c3820056b2cb4946e19d9fa9ee1dd398dc276dd
|
|
BLAKE2b-256 checksum How to use checksums |
53b1abdb33cddc2656e3d370775cbfa56e49fd0170f0847fd273bb8dc50c4c08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logRelease files / withruntime-1.1.0-py3-none-any.whl
| Download URL | withruntime-1.1.0-py3-none-any.whl |
|---|---|
| Size | 314.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4b51d9cbabc26d9f4608b54c692f6e33a186dba3f4a61880cc39b9f3c0f0230
|
|
BLAKE2b-256 checksum How to use checksums |
5808f20eb28e74b1a0466ffac09341637bc76bbb50c6b565f4cf458736e08211
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logSecurity for withruntime 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for withruntime-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.