daytona

Python SDK for Daytona

Apache-2.0 223 个版本 Python <4.0,>=3.9
Daytona Platforms Inc. <support@daytona.io>
安装
pip install daytona
poetry add daytona
pipenv install daytona
conda install daytona
描述

Daytona Python SDK

The official Python SDK for Daytona, a secure and elastic infrastructure for running AI-generated code. Daytona provides full composable computers — sandboxes — that you can manage programmatically using the Daytona SDK.

The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the documentation.

Installation

Install the package using pip:

pip install daytona

Get API key

Generate an API key from the Daytona Dashboard ↗ to authenticate SDK requests and access Daytona services. For more information, see the API keys documentation.

Configuration

Configure the SDK using environment variables or by passing a configuration object:

  • DAYTONA_API_KEY: Your Daytona API key
  • DAYTONA_API_URL: The Daytona API URL
  • DAYTONA_TARGET: Your target region environment (e.g. us, eu)
from daytona import Daytona, DaytonaConfig

# Initialize with environment variables
daytona = Daytona()

# Initialize with configuration object
config = DaytonaConfig(
    api_key="YOUR_API_KEY",
    api_url="YOUR_API_URL",
    target="us"
)

Create a sandbox

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

from daytona import Daytona, DaytonaConfig

config = DaytonaConfig(api_key="YOUR_API_KEY")
daytona = Daytona(config)
sandbox = daytona.create()
response = sandbox.process.code_run('print("Hello World")')

Examples and guides

Daytona provides examples and guides for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Daytona and other tools.

Create a sandbox with custom resources

Create a sandbox with custom resources (CPU, memory, disk).

from daytona import Daytona, CreateSandboxFromImageParams, Image, Resources

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromImageParams(
        image=Image.debian_slim("3.12"),
        resources=Resources(cpu=2, memory=4, disk=8)
    )
)

Create an ephemeral sandbox

Create an ephemeral sandbox that is automatically deleted when stopped.

from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(ephemeral=True, auto_stop_interval=5)
)

Create a sandbox from a snapshot

Create a sandbox from a snapshot.

from daytona import Daytona, CreateSandboxFromSnapshotParams

daytona = Daytona()
sandbox = daytona.create(
    CreateSandboxFromSnapshotParams(
        snapshot="my-snapshot-name",
        language="python"
    )
)

Execute Commands

Execute commands in the sandbox.

# Execute a shell command
response = sandbox.process.exec('echo "Hello, World!"')
print(response.result)

# Run Python code
response = sandbox.process.code_run('''
x = 10
y = 20
print(f"Sum: {x + y}")
''')
print(response.result)

File Operations

Upload, download, and search files in the sandbox.

# Upload a file
sandbox.fs.upload_file(b'Hello, World!', 'path/to/file.txt')

# Download a file
content = sandbox.fs.download_file('path/to/file.txt')

# Search for files
matches = sandbox.fs.find_files(root_dir, 'search_pattern')

Git Operations

Clone, list branches, and add files to the sandbox.

# Clone a repository
sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')

# List branches
branches = sandbox.git.branches('path/to/repo')

# Add files
sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])

Language Server Protocol

Create and start a language server to get code completions, document symbols, and more.

# Create and start a language server
lsp = sandbox.create_lsp_server('python', 'path/to/project')
lsp.start()

# Notify the lsp for the file
lsp.did_open('path/to/file.py')

# Get document symbols
symbols = lsp.document_symbols('path/to/file.py')

# Get completions
completions = lsp.completions('path/to/file.py', {"line": 10, "character": 15})

Code in _sync directory shouldn't be edited directly. It should be generated from the corresponding async code in the _async directory using the SDK generation scripts in the scripts directory.

版本列表
1.0.1 2025-05-02
0.190.1 2026-06-23
0.190.0 2026-06-23
0.189.0 2026-06-19
0.187.0 2026-06-11
0.186.0 2026-06-11
0.185.0 2026-06-09
0.184.0 2026-06-03
0.184.0a2 2026-06-02
0.184.0a1 2026-05-29
0.183.0 2026-05-29
0.182.0 2026-05-26
0.181.0 2026-05-25
0.180.0 2026-05-24
0.180.0a1 2026-05-22
0.179.0 2026-05-22
0.178.0 2026-05-21
0.176.0 2026-05-14
0.176.1a1 2026-05-14
0.175.0 2026-05-12
0.173.0 2026-05-07
0.172.0 2026-05-05
0.172.1a1 2026-05-06
0.171.0 2026-04-30
0.171.0rc1 2026-04-30
0.170.0 2026-04-29
0.169.0 2026-04-24
0.169.0a2 2026-04-21
0.168.0 2026-04-21
0.168.1a2 2026-04-21
0.168.1a1 2026-04-21
0.167.0 2026-04-16
0.167.0a1 2026-04-15
0.166.0 2026-04-15
0.165.0 2026-04-14
0.164.0 2026-04-10
0.164.0a1 2026-04-09
0.163.0 2026-04-09
0.163.0a1 2026-04-08
0.162.0 2026-04-08
0.161.0 2026-04-03
0.160.0 2026-04-02
0.159.0 2026-03-31
0.159.0a2 2026-03-30
0.158.1 2026-03-30
0.158.0 2026-03-27
0.157.0 2026-03-26
0.155.0 2026-03-24
0.155.1a2 2026-03-26
0.155.1a1 2026-03-25
0.154.0 2026-03-24
0.153.0 2026-03-19
0.152.1 2026-03-18
0.152.0 2026-03-17
0.151.0 2026-03-13
0.150.0 2026-03-10
0.149.0 2026-03-05
0.149.0rc2 2026-03-04
0.149.0rc1 2026-03-03
0.149.0a2 2026-03-04
0.149.0a1 2026-03-03
0.148.0 2026-02-27
0.147.0 2026-02-27
0.146.0 2026-02-25
0.146.1rc3 2026-02-26
0.146.1rc2 2026-02-26
0.146.1rc1 2026-02-26
0.145.0 2026-02-24
0.144.0 2026-02-20
0.143.0 2026-02-13
0.142.0 2026-02-12
0.141.0 2026-02-11
0.140.0 2026-02-10
0.139.0 2026-02-03
0.138.0 2026-01-30
0.136.0 2026-01-28
0.135.0 2026-01-26
0.134.0 2026-01-21
0.133.0 2026-01-20
0.132.0 2026-01-18
0.131.0rc4 2026-01-16
0.131.0rc3 2026-01-16
0.131.0rc2 2026-01-16
0.131.0rc1 2026-01-16
0.131.0a3 2026-03-03
0.131.0a2 2026-02-09
0.131.0a1 2026-01-17
0.130.0 2026-01-12
0.129.0 2026-01-08
0.128.1 2025-12-23
0.128.0 2025-12-23
0.128.2a1 2025-12-26
0.127.0 2025-12-19
0.127.0rc2 2025-12-19
0.127.0rc1 2025-12-19
0.125.0 2025-12-15
0.125.1a3 2025-12-18
0.125.1a2 2025-12-17
0.125.1a1 2025-12-17
0.125.0rc1 2025-12-12
0.124.0 2025-12-11
0.123.0 2025-12-09
0.122.0 2025-12-09
0.121.0 2025-12-03
0.120.0 2025-12-01
0.119.0 2025-11-27
0.118.0 2025-11-27
0.118.0a1 2025-11-24
0.117.0 2025-11-22
0.116.0 2025-11-21
0.116.0a1 2025-11-21
0.115.2 2025-11-19
0.115.1 2025-11-19
0.115.0 2025-11-14
0.115.1a7 2025-11-14
0.114.0 2025-11-13
0.114.0a1 2025-11-10
0.113.2 2025-11-13
0.113.1 2025-11-07
0.113.0 2025-11-06
0.112.3 2025-11-05
0.112.2 2025-10-31
0.112.1 2025-10-27
0.112.0 2025-10-24
0.112.0.dev462455 2025-10-20
0.112.0.dev4317853 2025-10-28
0.112.3a2 2025-11-04
0.112.3a1 2025-11-03
0.112.2rc1 2025-10-28
0.111.1 2025-10-21
0.111.0 2025-10-18
0.110.2 2025-10-14
0.110.1 2025-10-11
0.110.0 2025-10-11
0.109.0 2025-10-09
0.109.0a2 2025-10-09
0.109.0a1 2025-10-08
0.108.1 2025-10-07
0.108.0 2025-10-03
0.108.1rc1 2025-10-07
0.108.0rc1 2025-10-03
0.107.1 2025-10-02
0.107.0rc2 2025-09-30
0.107.0rc1 2025-09-26
0.106.5 2025-10-01
0.106.4 2025-09-30
0.106.1 2025-09-26
0.106.0a3 2025-09-26
0.106.0a2 2025-09-26
0.106.0a1 2025-09-26
0.105.1 2025-09-25
0.105.0 2025-09-25
0.104.0rc2 2025-09-22
0.104.0rc1 2025-09-22
0.103.0 2025-09-19
0.103.0rc3 2025-09-17
0.103.0rc2 2025-09-17
0.103.0rc1 2025-09-17
0.102.0 2025-09-17
0.102.0rc2 2025-09-12
0.102.0rc1 2025-09-11
0.28.0rc1 2025-09-09
0.27.1 2025-09-11
0.27.0 2025-09-08
0.27.0rc1 2025-09-05
0.26.0 2025-09-03
0.26.0rc2 2025-09-01
0.26.0rc1 2025-08-20
0.26.0a12 2025-08-14
0.26.0a11 2025-08-14
0.25.6 2025-08-25
0.25.5 2025-08-06
0.25.4 2025-08-01
0.25.3 2025-08-01
0.25.1 2025-07-30
0.25.0 2025-07-29
0.25.2a1 2025-08-01
0.25.2a0 2025-08-01
0.24.5 2025-07-26
0.24.4 2025-07-26
0.24.2 2025-07-21
0.24.1 2025-07-16
0.24.0 2025-07-16
0.23.0 2025-07-14
0.22.1 2025-07-14
0.22.0 2025-07-08
0.22.2a0 2025-07-10
0.22.0a6 2025-07-04
0.22.0a5 2025-07-04
0.22.0a4 2025-07-01
0.22.0a3 2025-07-01
0.22.0a2 2025-07-01
0.22.0a1 2025-06-25
0.22.0a0 2025-06-25
0.21.8 2025-07-04
0.21.7 2025-07-03
0.21.6 2025-07-02
0.21.5 2025-06-30
0.21.4 2025-06-24
0.21.3 2025-06-22
0.21.2 2025-06-20
0.21.1 2025-06-17
0.21.0 2025-06-15
0.21.5a8 2025-06-24
0.21.4a5 2025-06-23
0.21.4a16 2025-06-23
0.21.4a15 2025-06-23
0.21.4a14 2025-06-23
0.21.4a12 2025-06-23
0.21.4a11 2025-06-23
0.21.0a2 2025-06-13
0.21.0a1 2025-06-13
0.20.2 2025-06-04
0.20.0 2025-06-04
0.19.0 2025-06-02
0.19.0a2 2025-05-28
0.19.0a0 2025-05-26
0.18.2 2025-05-29
0.18.1 2025-05-23
0.18.0 2025-05-22
0.17.0 2025-05-22
0.1.0 2025-04-24
0.169a1 2026-04-21