Skip to content

Configuration

The Daytona SDK provides flexible configuration options to customize its behavior and connection settings.

Configuration Options

Daytona SDK provides an option to configure settings using the DaytonaConfig class in Python and TypeScript. The DaytonaConfig class accepts the following parameters:

  • api_key: Your Daytona API key
  • server_url: URL of your Daytona server
  • target: Daytona Target to create the Sandboxes on.
from daytona_sdk import DaytonaConfig
config = DaytonaConfig(
api_key="your-api-key",
server_url="your-server-url",
target="local"
)

Environment Variables

Daytona SDK supports environment variables for configuration. The SDK automatically looks for these environment variables:

VariableDescriptionDefault
DAYTONA_API_KEYYour Daytona API key.None
DAYTONA_SERVER_URLURL of your Daytona server.None
DAYTONA_TARGETDaytona Target to create the Sandboxes on.”local”

Setting Environment Variables

Daytona SDK can read configuration from environment variables. You can set these environment variables using the following methods:

Using a .env File

Create a .env file in your project root directory:

Terminal window
DAYTONA_API_KEY=your-api-key
DAYTONA_SERVER_URL=https://your-server-url
DAYTONA_TARGET=local
  • DAYTONA_API_KEY: Your Daytona API key.
  • DAYTONA_SERVER_URL: URL of your Daytona server.
  • DAYTONA_TARGET: Daytona Target to create the Sandboxes on.

Using Shell Environment

Set environment variables in your shell:

Terminal window
export DAYTONA_API_KEY=your-api-key
export DAYTONA_SERVER_URL=https://your-server-url

Configuration Precedence

The SDK uses the following precedence order for configuration (highest to lowest):

  1. Explicitly passed configuration in code.
  2. Environment variables.
  3. Configuration file.
  4. Default values.