Skip to content

Daytona Documentation

View as Markdown

Daytona is an open-source, secure and elastic infrastructure for running AI-generated code. Daytona provides full composable computers — sandboxes — with complete isolation, a dedicated kernel, filesystem, network stack, and allocated vCPU, RAM, and disk.

Sandboxes are the core component of the Daytona platform, spinning up in under 90ms from code to execution and running any code in Python, TypeScript, and JavaScript. Built on OCI/Docker compatibility, massive parallelization, and unlimited persistence, sandboxes deliver consistent, predictable environments for agent workflows.

Agents and developers interact with sandboxes programmatically using the Daytona SDKs, API, and CLI. Operations span sandbox lifecycle management, filesystem operations, process and code execution, and runtime configuration. Our stateful environment snapshots enable persistent agent operations across sessions, making Daytona the ideal foundation for AI agent architectures.

Open the Daytona Dashboard ↗ to create your account. Daytona supports account creation using an email and password, or by connecting your Google or GitHub account.

Generate an API key from the Daytona Dashboard ↗ or using the Daytona API to authenticate SDK requests and access Daytona services. Daytona supports multiple options to configure your environment and API keys: in code, environment variables, .env file, and default values.

Install the Daytona Python, TypeScript, Ruby, Go, or Java SDKs to interact with sandboxes.

Terminal window
pip install daytona

Create a sandbox to run your code securely in an isolated environment.

# Import the Daytona SDK
from daytona import Daytona, DaytonaConfig
# Define the configuration
config = DaytonaConfig(api_key="YOUR_API_KEY") # Replace with your API key
# Initialize the Daytona client
daytona = Daytona(config)
# Create the Sandbox instance
sandbox = daytona.create()

Create a program that runs code inside a sandbox. The following snippets are examples of “Hello World” programs that run securely inside a sandbox.

# Import the Daytona SDK
from daytona import Daytona, DaytonaConfig
# Define the configuration
config = DaytonaConfig(api_key="YOUR_API_KEY") # Replace with your API key
# Initialize the Daytona client
daytona = Daytona(config)
# Create the Sandbox instance
sandbox = daytona.create()
# Run the code securely inside the Sandbox
response = sandbox.process.code_run('print("Hello World")')
# Check the response
if response.exit_code != 0:
print(f"Error: {response.exit_code} {response.result}")
else:
print(response.result)
# Clean up
sandbox.delete()

By following the steps above, you successfully create a Daytona account, obtain an API key, install the SDK, create a sandbox, write code, and run it securely in a sandbox.

Use the following resources to interact with sandboxes: