Daytona Documentation
Daytona is an open-source, secure and elastic infrastructure for running AI-generated code.
Daytona provides isolated sandbox environments that you can manage programmatically using the Daytona SDK to run and control code execution.
Daytona SDK is available for Python and TypeScript interfaces.
Create an account
Open the Daytona Dashboard ↗ and create your account. Daytona supports account creation using an email and password, or by connecting your Google or GitHub account.
Obtain an API key
Generate an API key from the Daytona Dashboard ↗ to authenticate SDK requests and access Daytona services. Save the API key securely, as it won’t be shown again.
Install the SDK
Install the Daytona SDK to interact with sandboxes from your code using Python or TypeScript.
pip install daytonanpm install @daytonaio/sdkCreate a Sandbox
Create a Daytona Sandbox to run your code securely in an isolated environment.
# Import the Daytona SDKfrom daytona import Daytona, DaytonaConfig
# Define the configurationconfig = DaytonaConfig(api_key="YOUR_API_KEY") # Replace with your API key
# Initialize the Daytona clientdaytona = Daytona(config)
# Create the Sandbox instancesandbox = daytona.create()// Import the Daytona SDKimport { Daytona } from '@daytonaio/sdk';
// Initialize the Daytona clientconst daytona = new Daytona({ apiKey: 'YOUR_API_KEY' }); // Replace with your API key
// Create the Sandbox instanceconst sandbox = await daytona.create({ language: 'typescript',});Write code
Create a program that runs code inside a Daytona Sandbox. The following snippet is an example “Hello World” program that runs securely inside a Daytona Sandbox.
main.py
# Import the Daytona SDKfrom daytona import Daytona, DaytonaConfig
# Define the configurationconfig = DaytonaConfig(api_key="YOUR_API_KEY") # Replace with your API key
# Initialize the Daytona clientdaytona = Daytona(config)
# Create the Sandbox instancesandbox = daytona.create()
# Run the code securely inside the Sandboxresponse = sandbox.process.code_run('print("Hello World")')
# Check the responseif response.exit_code != 0: print(f"Error: {response.exit_code} {response.result}")else: print(response.result)
# Clean upsandbox.delete()index.mts
// Import the Daytona SDKimport { Daytona } from '@daytonaio/sdk'
// Initialize the Daytona clientconst daytona = new Daytona({ apiKey: 'YOUR_API_KEY' }) // Replace with your API key
// Create the Sandbox instanceconst sandbox = await daytona.create({ language: 'typescript',})
// Run the code securely inside the Sandboxconst response = await sandbox.process.codeRun('console.log("Hello World")')
// Check the responseif (response.exitCode !== 0) { console.error(`Error: ${response.exitCode} ${response.result}`)} else { console.log(response.result)}
// Clean upawait sandbox.delete()Run code
Run the program to execute your code in a secure and isolated Daytona Sandbox environment.
python main.pynpx tsx index.mtsHello WorldSummary
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 Daytona Sandbox.
Introduction
- Quick Start
- Getting Started
Learn about Daytona SDK and how it can help you manage your development environments. - Configuration
Get started with Daytona SDK and learn how to use and configure your development environments. - Sandboxes
Learn how to create, manage, and remove Sandboxes using the Daytona SDK. - Snapshots
Learn how to create, manage and remove Snapshots using the Daytona SDK. - Declarative Builder
Learn how to dynamically build Snapshots from Docker/OCI compatible images using the Daytona SDK. - Volumes
Learn how to manage volumes in your Daytona Sandboxes.
Account management
Agent Toolbox
- File System
Learn how to manage files and directories in your Sandboxes using the Daytona SDK. - Git Operations
Learn how to manage Git repositories in your Sandboxes using the Daytona SDK. - Language Server Protocol
Learn how to use Language Server Protocol (LSP) support in your Sandboxes using the Daytona SDK. - Process & Code Execution
Learn about running commands and code in isolated environments using the Daytona SDK. - Pseudo Terminal (PTY)
Learn how to manage PTY sessions in your Sandboxes using the Daytona SDK. - Log Streaming
Learn how to stream logs from your Sandboxes using the Daytona SDK.
Computer Use
Other
- Web Terminal
Web Terminal access to Daytona Sandboxes. - Network Limits
Network egress limits for Daytona Sandboxes. - SSH Access
SSH access to Daytona Sandboxes. - Preview & Authentication
Preview URLs and authentication tokens. - Custom Domain Authentication
Customize the preview proxy with your own domain and logic. - Audit Logs
Monitor and track activities across your Daytona organization. - Webhooks
Receive real-time notifications when events occur in your Daytona organization. - Regions
Setting the region to spin up Daytona Sandboxes in. - MCP Server
- Data Analysis with AI