Skip to main content

den-sdk

Python SDK for Den — the self-hosted sandbox runtime for AI agents.

100 sandboxes on E2B = ~$600/hour. 100 sandboxes on Den = one $5/month server.

Installation

pip install den-sdk
# or
uv add den-sdk

Quick Start

from den import Den

client = Den("http://localhost:8080", api_key="your-key")

# Create a sandbox
sandbox = client.sandbox.create(image="ubuntu:22.04")

# Execute a command
result = sandbox.exec(["python3", "-c", "print('Hello from Den!')"])
print(result.stdout)  # Hello from Den!

# Read/write files
sandbox.write_file("/tmp/hello.py", "print('hello world')")
content = sandbox.read_file("/tmp/hello.py")

# List files
files = sandbox.list_files("/tmp")

# Clean up
sandbox.destroy()

Async Support

import asyncio
from den import Den

async def main():
    client = Den("http://localhost:8080", api_key="your-key")

    sandbox = await client.sandbox.acreate(image="ubuntu:22.04")
    result = await sandbox.aexec(["echo", "async works!"])
    print(result.stdout)
    await sandbox.adestroy()

asyncio.run(main())

Storage

from den import Den, StorageConfig, VolumeMount

client = Den("http://localhost:8080")

# Persistent volume
sandbox = client.sandbox.create(
    image="ubuntu:22.04",
    storage=StorageConfig(
        volumes=[VolumeMount(name="my-data", mount_path="/data")]
    ),
)

Snapshots

# Save state
snapshot = sandbox.snapshot(name="after-setup")

# Restore from snapshot
restored = client.sandbox.restore_snapshot(snapshot.id)

Sandbox Management

# List all sandboxes
sandboxes = client.sandbox.list()

# Get a specific sandbox
sb = client.sandbox.get("sandbox-id")

# Stop a sandbox
sandbox.stop()

# Get sandbox stats
stats = sandbox.stats()

Features

  • Sandbox lifecycle management (create, list, get, stop, destroy)
  • Command execution with timeout and environment variables
  • File operations (read, write, list, mkdir, delete)
  • Persistent volumes, shared volumes, tmpfs configuration
  • Snapshot/restore
  • Port forwarding
  • Async support via httpx
  • Type-safe with Pydantic models

Requirements

  • Python >= 3.10
  • Den server running (see Den repo)

License

MIT

Release files for den-sdk 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for den-sdk 0.0.6
File Size Uploaded
den_sdk-0.0.6.tar.gz 30.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for den-sdk 0.0.6
File Interpreter ABI Platform
den_sdk-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / den_sdk-0.0.6.tar.gz

Download URL den_sdk-0.0.6.tar.gz
Size 30.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c0aef72ea40f2fd69df63877f6cac7587977aac436d20e500a002d64f5efc8ca
BLAKE2b-256 checksum
How to use checksums
eb5f22f992dc6b7a6fea418fac2367edea7f68a6cd401af1c5a0e741065b390e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / den_sdk-0.0.6-py3-none-any.whl

Download URL den_sdk-0.0.6-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f94ec90813b344765395a13c3f2633b3577dca99faddf9ca56d2416abf90660e
BLAKE2b-256 checksum
How to use checksums
981ca082fdda183c25cd24f07850746526fb87f37185620589b25b0ecb8dbc5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page