Podflare — Python SDK
Cloud sandbox for AI agents. Fork in 100 ms, persistent Python REPL, run_code, upload/download, merge_into, interactive PTY sessions (pty.create / attach / sendInput / resize / kill).
- Docs: https://docs.podflare.ai
- Dashboard: https://dashboard.podflare.ai — mint an API key in seconds
- GitHub: https://github.com/PodFlare-ai/podflare
Install
pip install podflare
Quickstart
from podflare import Sandbox
# Create a sandbox (persistent Python REPL, preloaded libs on python-datasci)
sbx = Sandbox(template="python-datasci")
# Execute code — state persists across calls
sbx.run_code("x = 42")
print(sbx.run_code("print(x * 2)").stdout) # "84"
# Fork — spawn N copies of the running sandbox
children = sbx.fork(n=5)
children[0].run_code("x = 100") # isolated per branch
# Merge a branch back into the parent
sbx.merge_into(children[0])
# Upload + download files
sbx.upload("data.csv", open("local.csv", "rb").read())
sbx.run_code("import pandas as pd; df = pd.read_csv('data.csv')")
# Destroy
sbx.close()
Configuration
| Env var | Default | What it does |
|---|---|---|
PODFLARE_API_KEY |
(none — required) | Bearer token from the dashboard (pf_live_...). |
PODFLARE_HOSTD_URL |
https://api.podflare.ai |
Override for self-hosted or staging deployments. |
You can also pass them as constructor arguments:
from podflare import Sandbox
sbx = Sandbox(
host="https://api.podflare.ai",
api_key="pf_live_...",
template="default",
)
Streaming
with Sandbox() as s:
for ev in s.run_code_stream("for i in range(3): print(i)"):
if ev.type == "stdout":
print(ev.data, flush=True)
Interactive PTY — sandbox.pty.*
When an LLM-generated command needs a real terminal (interactive
installers, REPLs, npm init, apt install, or anything that checks
isatty()), reach for the PTY namespace. It gives you a first-class
pseudo-terminal inside the sandbox, with reconnect support for
long-running sessions that outlive your process.
from podflare import Sandbox
with Sandbox(region="eu") as sbx:
# Spawn a real tty. timeout_ms=0 keeps the session alive until
# close() or the sandbox's max_lifetime.
pty = sbx.pty.create(
cmd="npm init",
cols=120, rows=40,
on_data=lambda chunk: print(chunk.decode(), end=""),
timeout_ms=0,
)
# Send keystrokes — strings are UTF-8, bytes are raw
pty.send_input("\r" * 9) # accept every npm init default
pty.send_input(b"\x03") # Ctrl-C
pty.resize(cols=200, rows=50) # child receives SIGWINCH
exit_code = pty.wait() # blocks until the child exits
Reconnect across turns (survive network blips)
# Turn 1 — kick off a long build
pty = sbx.pty.create(cmd="bash", timeout_ms=0)
pty.send_input(b"./build.sh 2>&1 | tee /tmp/build.log\n")
pty_id = pty.id # persist this across your agent's turns
# Turn 2 (different process, maybe hours later)
pty = sbx.pty.attach(pty_id, on_data=stream_to_user)
# Replays the last 1 MiB of buffered output, then tails live.
# Same running bash — pty.send_input still works.
Full API: https://docs.podflare.ai/concepts/pty
Framework adapters
First-class integrations:
- OpenAI Agents SDK —
podflare.adapters.openai_agents - Anthropic
code_executiontool —podflare.adapters.anthropic - MCP server (
podflare-mcpnpm package) for Claude Desktop / Cursor / Cline / Zed
See the integrations docs for copy-paste examples.
Links
License
Proprietary.
Metadata
Release files for podflare 0.0.22
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 |
|---|---|---|---|---|
| podflare-0.0.22.tar.gz | 27.8 kB | Without provenance | Details for podflare-0.0.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| podflare-0.0.22-py3-none-any.whl | Python 3 | none | any | Details for podflare-0.0.22-py3-none-any.whl |
Total release size: 60.5 kB
Release files / podflare-0.0.22.tar.gz
| Download URL | podflare-0.0.22.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aaff39519e401a6ff9c36d36b7b7495a19a2f3170b211a90ebb55b5522246d2b
|
|
BLAKE2b-256 checksum How to use checksums |
97aeedabcbe2039de1af03489dfc084b9834b7eea5e542469cbd8889fe646440
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / podflare-0.0.22-py3-none-any.whl
| Download URL | podflare-0.0.22-py3-none-any.whl |
|---|---|
| Size | 32.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15096e68c8ce05eb8b7733326e3081b0704045792cbde31196a380a4ea09b176
|
|
BLAKE2b-256 checksum How to use checksums |
a36b6f6c04cdc1bbc9ec442104c6f810b2a3260cd3276cc405d208f7ccac9f3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for podflare 0.0.22
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.