The Daytona Python SDK is the official Python library for Daytona, an open-source, secure, and elastic infrastructure for running AI-generated code. It provides interfaces for managing sandboxes (isolated execution environments), file system operations, Git operations, language server protocol support, and process and code execution. The library is actively maintained and currently at version 0.166.0, with regular updates. [1, 13]
Install & Compatibility
Where this runs
tested against v0.187.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 83MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 11.0s · import 0.000s · 84MB
86MB installed
● package 86MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from daytona_sdk import AsyncDaytona
This quickstart demonstrates how to initialize the Daytona SDK, create an isolated sandbox environment, execute Python code within it, and then clean up the sandbox. Ensure your `DAYTONA_API_KEY` is set as an environment variable or passed directly to `DaytonaConfig`. [3, 6, 13]
import os
from daytona import Daytona, DaytonaConfig
# Configure with API key from environment variable (recommended) or direct string
api_key = os.environ.get("DAYTONA_API_KEY", "") # Replace with your actual key or ensure env var is set
if not api_key:
print("Warning: DAYTONA_API_KEY not found in environment variables. Please set it or pass it directly.")
# For demonstration purposes, you might uncomment and replace:
# api_key = "YOUR_API_KEY_HERE"
# if api_key == "YOUR_API_KEY_HERE":
# raise ValueError("Please provide a valid Daytona API key.")
config = DaytonaConfig(api_key=api_key)
daytona = Daytona(config)
try:
# Create a sandbox
print("Creating Daytona sandbox...")
sandbox = daytona.create()
print(f"Created Sandbox ID: {sandbox.id}")
# Run code securely inside the Sandbox
print("Running code in sandbox...")
response = sandbox.process.code_run('print("Hello World from Daytona!")')
print(f"Code Output: {response.result}")
# Optional: Execute a shell command
# shell_response = sandbox.process.exec("ls -la")
# print(f"Shell Command Output:\n{shell_response.result}")
finally:
# Clean up the sandbox (important to release resources)
if 'sandbox' in locals() and sandbox:
print(f"Deleting Sandbox ID: {sandbox.id}...")
sandbox.delete()
print("Sandbox deleted.")
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.