Skip to content

Environment Configuration

View as Markdown

Daytona supports multiple methods to configure your environment, in order of precedence:

  1. Configuration in code
  2. Environment variables
  3. .env file
  4. Default values

To configure your environment in code, use the DaytonaConfig class. The DaytonaConfig class accepts the following parameters:

  • api_key: Your Daytona API Key
  • api_url: URL of your Daytona API
  • target: Target region to create the Sandboxes on (us / eu)
from daytona import DaytonaConfig
config = DaytonaConfig(
api_key="YOUR_API_KEY",
api_url="YOUR_API_URL",
target="us"
)

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

VariableDescriptionRequired
DAYTONA_API_KEYYour Daytona API key.Yes
DAYTONA_API_URLURL of your Daytona API.No
DAYTONA_TARGETDaytona Target to create the sandboxes on.No

Set environment variables in your shell using the following methods:

Terminal window
export DAYTONA_API_KEY=your-api-key
export DAYTONA_API_URL=https://your-api-url
export DAYTONA_TARGET=us

Set the environment variables in a .env file using the following format:

Terminal window
DAYTONA_API_KEY=YOUR_API_KEY
DAYTONA_API_URL=https://your_api_url
DAYTONA_TARGET=us

Daytona provides an additional DAYTONA_HAPPY_EYEBALLS_DELAY environment variable for HTTP transport tuning in the async Python SDK. Use it to reduce intermittent async connection failures, such as aiohttp.ClientConnectorError, that can occur on dual-stack (IPv4/IPv6) networks.

VariableDescriptionRequired
DAYTONA_HAPPY_EYEBALLS_DELAYControls aiohttp Happy Eyeballs (IPv4/IPv6 connection race) delay in seconds.No
  • unset or empty: use aiohttp default behavior
  • none (case-insensitive): disable the IPv4/IPv6 race
  • non-negative float (for example 0.25): set an explicit delay in seconds
Terminal window
# Disable Happy Eyeballs
export DAYTONA_HAPPY_EYEBALLS_DELAY=none
# Or set an explicit delay in seconds
export DAYTONA_HAPPY_EYEBALLS_DELAY=0.25

If no configuration is provided, Daytona will use its built-in default values:

OptionValue
API URLhttps://app.daytona.io/api
TargetDefault region for the organization