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, TypeScript and Ruby 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, TypeScript or Ruby.
pip install daytonanpm install @daytonaio/sdkgem install daytonaCreate 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',});Create a file named: main.rb
require 'daytona'
# Initialize the Daytona clientconfig = Daytona::Config.new(api_key: 'your-api-key')daytona = Daytona::Daytona.new(config)
# Create the Sandbox instancesandbox = daytona.create
# Run the code securely inside the Sandboxresponse = sandbox.process.code_run(code: 'print("Hello World from code!")')if response.exit_code != 0 puts "Error: #{response.exit_code} #{response.result}"else puts response.resultend
# Clean updaytona.delete(sandbox)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()main.rb
require 'daytona'
# Initialize the Daytona clientconfig = Daytona::Config.new(api_key: 'your-api-key')daytona = Daytona::Daytona.new(config)
# Create the Sandbox instancesandbox = daytona.create
# Run the code securely inside the Sandboxresponse = sandbox.process.code_run(code: 'print("Hello World")')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
Sandbox
- Environment
Get started with Daytona SDK and learn how to use and configure your development environments. - 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. - Regions
Region types and custom infrastructure.
Agent Tools
- 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. - MCP Server
- Computer Use