Skip to content

Configuration

Set Up Your Environment Variables

To authenticate with Daytona, you need an API key. You can obtain an API key from the Daytona platform.

  1. Navigate to the Daytona Dashboard.
  2. Go to API Keys.
  3. Click the Create Key button.
  4. Add your API key to your .env file by setting the DAYTONA_API_KEY environment variable.
  5. Define the Daytona server URL in your .env file by setting the DAYTONA_SERVER_URL environment variable.

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="us"
)

Environment Variables

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

VariableDescriptionOptional
DAYTONA_API_KEYYour Daytona API key.
DAYTONA_SERVER_URLURL of your Daytona server.Yes
DAYTONA_TARGETDaytona Target to create the Sandboxes on.Yes

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=us
  • 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.