Runtime Python SDK and CLI
Project description
runtime-sdk
Python SDK and CLI for Runtime.
Install
uv tool install runtime-sdk
To upgrade an existing install:
uv tool upgrade runtime-sdk
Configure
The CLI talks to http://127.0.0.1:8080 by default. Override it with:
export RUNTIME_BASE_URL=https://api.runruntime.dev
Or pass --base-url per command.
Usage
# Auth
runtime # first run in a real terminal prompts for email + verification code, then creates your first computer
runtime login # interactive email + verification code flow
runtime login you@example.com
runtime verify 123456
runtime whoami
runtime logout
runtime login --api-key rt_live_...
runtime api-keys list
runtime api-keys create "my laptop"
runtime api-keys revoke 123
# Computers
runtime create # creates a computer with the starter app already published
runtime create myapp --command "python3 app.py" --cwd /home/ubuntu --port 3000
runtime enter <name-or-id> # accepts slug/name like test, or the computer id
runtime list
runtime info <id>
runtime start <id>
runtime run <id> "echo hello" # one-shot foreground command only
runtime run <id> "apt install -y nodejs" --uid 0
runtime startup show <id>
runtime startup set <id> --command "python3 app.py" --cwd /home/ubuntu --port 3000
runtime startup clear <id> # low-level durable service config
runtime service show <id> # user-facing alias for the durable published app
runtime service clear <id>
runtime publish <id> 3000 # promote the running app on port 3000 to the public durable app
runtime delete <id>
# Inside a running computer, the helper installed by Runtime can manage the
# durable app without leaving the sandbox:
# runtime-env publish 3000
# runtime-env service show
# runtime-env service clear
Python
from runtime_sdk import RuntimeClient
client = RuntimeClient(base_url="https://api.runruntime.dev", api_key="rt_live_...")
# Create a computer. New computers start with the starter app already published.
computer = client.create_computer()
print(computer["public_url"]) # https://goldbird.runruntime.dev
# Or create one with an explicit durable app command.
# That saved service is replayed after cold restore / start.
app = client.create_computer(
slug="myapp",
command="python3 app.py",
cwd="/home/ubuntu",
port=3000,
)
# Run a command
result = client.run_command(computer["id"], "echo hello")
print(result["stdout"])
# Wake a cold computer explicitly
client.start_computer(app["id"])
# Promote the running app on a local port to the durable public app.
# Runtime inspects the listening process and saves its command + cwd when possible.
client.publish_port(computer["id"], 3000)
# List, info, delete
computers = client.list_computers()
info = client.get_computer(computer["id"])
client.delete_computer(computer["id"])
Development
For fast local backend iteration:
make local-backend
For deploying and testing against the Hetzner production server:
make sync SERVER_IP=x.x.x.x SSH_USER=root
make smoke
Use make deploy instead of make sync when migrations, env
files, Caddy, or systemd units changed.
Cold restore and explicit runtime start replay the saved published app command.
New computers seed that durable app from the starter workspace. Later,
runtime publish <id> <port> can promote a running listener into the saved
public app definition by inspecting the live process. Inside a running computer,
runtime-env publish <port> does the same thing using a computer-scoped token
installed by Runtime. runtime service show|clear and runtime-env service show|clear expose that same durable app state directly. The low-level
runtime startup ... commands still map to the same durable state. A one-off
runtime run stays one-shot: the filesystem is restored after going cold, but
that ad-hoc process is not.
Run the SDK unit tests through the backend project environment:
uv run python -m unittest scripts.tests.test_runtime_sdk
Release
Preview the next release without changing files:
./scripts/release_runtime_sdk.sh --dry-run
Publish a patch release:
./scripts/release_runtime_sdk.sh --publish
Publish a different version bump:
./scripts/release_runtime_sdk.sh --bump minor --publish
The script loads backend/.env automatically, so UV_PUBLISH_TOKEN can live there.
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 runtime_sdk-0.4.13.tar.gz.
File metadata
- Download URL: runtime_sdk-0.4.13.tar.gz
- Upload date:
- Size: 24.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ffafac03cd461eefbbf271b45e78a3f575b968e0244f8a600726ebf4d56f74b
|
|
| MD5 |
ce31595e916becbc3abf7a630ba08ff1
|
|
| BLAKE2b-256 |
d83c4716646adc7bf58fa08aab0ba26af0ee93495f3d0de05980221d175af101
|
File details
Details for the file runtime_sdk-0.4.13-py3-none-any.whl.
File metadata
- Download URL: runtime_sdk-0.4.13-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de954e543af5b9b0b7eb2267eb565911f675edcccbd69177de8917253d845ead
|
|
| MD5 |
bd0c358361e200bc7a57309b66a914da
|
|
| BLAKE2b-256 |
2b81f008a6dde9606151d8ede5ccdd6566240182f5f8f47e86e2950fc5d892f8
|