Skip to main content

Python SDK for PandaStack — open-source Firecracker microVM sandboxes

Project description

PandaStack Python SDK

Python SDK for PandaStack, open-source Firecracker microVM sandboxes for AI agents and code execution.

Install

pip install pandastack

Auth

Create a token in the PandaStack dashboard, then export it:

export PANDASTACK_API_KEY=psk_...
# Optional for self-hosted/dev:
export PANDASTACK_API=http://localhost:8080

Client() also reads ~/.config/pandastack/config.json when environment variables are unset.

Quickstart

from pandastack import Sandbox

with Sandbox.create(template="code-interpreter") as sb:
    result = sb.run_code("print(2 + 2)")
    print(result.stdout.strip())

Explicit client

from pandastack import Client

client = Client(api_key="psk_xxx", api_url="https://api.pandastack.ai")
sb = client.sandboxes.create(template="code-interpreter")
try:
    print(sb.exec("ls -la").stdout)
finally:
    sb.kill()

Filesystem

sb.filesystem.write("/home/panda/hello.txt", "hello")
print(sb.filesystem.read("/home/panda/hello.txt"))
sb.filesystem.upload("local.csv", "/home/panda/local.csv")
sb.filesystem.download("/home/panda/out.png", "out.png")

Commands and logs

result = sb.commands.run("python3 --version", timeout=10)
for line in sb.logs(stream="both", follow=False):
    print(line)

Lifecycle

sb.set_ttl(600)
sb.set_persistent(True)
print(sb.lifecycle())
sb.pause()
sb.resume()
snapshot_id = sb.snapshot()

Templates

from pandastack import templates

print(templates.list())
build = templates.build("my-template", rootfs_tar="rootfs.tar", size_mb=2048)
print(build.status)
templates.delete("my-template")

Tokens

from pandastack import tokens

new_token = tokens.create("ci")
print(new_token.token)
for token in tokens.list():
    print(token.prefix, token.name)
tokens.revoke(new_token.prefix)

The old pandastack import remains as a deprecated compatibility alias. Use pandastack for new code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandastack-0.3.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pandastack-0.3.0-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

Details for the file pandastack-0.3.0.tar.gz.

File metadata

  • Download URL: pandastack-0.3.0.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pandastack-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c92f439989937fefe2daa0b2514ebaa7a43a279843c9e26fb979303cf5921983
MD5 ee4e436b79489a47f9045667656bef19
BLAKE2b-256 bfe89b03b5d79e2752e0a704df9019463a69c318b9cdaab6614f8696d4e8ba58

See more details on using hashes here.

File details

Details for the file pandastack-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pandastack-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 39.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pandastack-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8765b06249e2edf350cf05adfa8603d2b2f84e595b3ebf231dc0cca4162a382
MD5 978f5cf5b0efe6a384097d8b3a5f68b3
BLAKE2b-256 b2e0338268701f6716d55ee077f1c66ed2bbf194615b1b311d29110aad60c810

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page