Python SDK for Fly.io Sprites: computers for agents. Sprite management, remote command execution, filesystems, checkpoints, services, and network policy from Python.
Actively maintained. Last release 8 weeks ago, commits in 10 of the last 26 weeks. A safe choice.
pip install sprites-pySprites Python SDK
Python SDK for Sprites, providing sprite management, remote command execution, filesystem access, checkpoints, services, and network policy controls.
Installation
pip install sprites-py
Quick Start
import os
from sprites import SpritesClient
client = SpritesClient(token=os.environ["SPRITE_TOKEN"])
sprite = client.create_sprite(os.environ["SPRITE_NAME"])
# Run a command
result = sprite.run("echo", "hello", capture_output=True)
print(result.stdout.decode()) # "hello\n"
# Or use the Go-style API
cmd = sprite.command("ls", "-la")
output = cmd.output()
print(output.decode())
sprite.destroy()
API Overview
Async API
Async applications can use the matching native asyncio client. Its network
operations use httpx.AsyncClient, and command execution runs directly on the
caller's event loop.
from sprites import AsyncSpritesClient
async with AsyncSpritesClient(token="your-token") as client:
sprite = await client.create_sprite("my-sprite")
output = await sprite.command("echo", "hello").output()
result = await sprite.run("uname", "-a", capture_output=True)
config = sprite.filesystem("/app") / "config.json"
await config.write_text('{"debug": true}')
print(await config.read_text())
async for path in (sprite.filesystem("/app") / ".").iterdir():
print(path.name)
await sprite.destroy()
AsyncSpritesClient deliberately returns distinct AsyncSprite, AsyncCmd,
and AsyncSpritePath objects. This keeps every I/O method predictably
awaitable while preserving the existing synchronous API unchanged.
SpritesClient
from sprites import ListOptions, SpritesClient, URLSettings
client = SpritesClient(
token="your-token",
base_url="https://api.sprites.dev", # optional
timeout=30.0, # optional
control_mode=False, # optional multiplexed exec transport
)
# Create a sprite
sprite = client.create_sprite(
"my-sprite",
url_settings=URLSettings(auth="sprite", private_access="admins"),
labels=["dev"],
wait_for_capacity=True,
runtime="dev",
)
# Get a sprite handle (doesn't create it)
sprite = client.sprite("my-sprite")
# Get a sprite with populated metadata
sprite = client.get_sprite("my-sprite")
# List sprites
page = client.list_sprites(ListOptions(prefix="my-", bulk_load=True))
for item in page.sprites:
print(item.name, item.status, item.labels)
# Update URL settings and labels
updated = client.update_sprite(
"my-sprite",
url_settings=URLSettings(auth="public"),
labels=["dev", "public-demo"],
)
# Omitted mutable fields are left unchanged by the API.
client.update_sprite("my-sprite", labels=["dev"])
# Destroy a sprite
client.destroy_sprite("my-sprite")