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 keyserver_url
: URL of your Daytona servertarget
: 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")
import { DaytonaConfig } from '@daytonaio/sdk';
const config: DaytonaConfig = { apiKey: "your-api-key", serverUrl: "your-server-url", target: "local"};
Environment Variables
Daytona SDK supports environment variables for configuration. The SDK automatically looks for these environment variables:
Variable | Description | Default |
---|---|---|
DAYTONA_API_KEY | Your Daytona API key. | None |
DAYTONA_SERVER_URL | URL of your Daytona server. | None |
DAYTONA_TARGET | Daytona 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:
DAYTONA_API_KEY=your-api-keyDAYTONA_SERVER_URL=https://your-server-urlDAYTONA_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:
export DAYTONA_API_KEY=your-api-keyexport DAYTONA_SERVER_URL=https://your-server-url
$env:DAYTONA_API_KEY="your-api-key"$env:DAYTONA_SERVER_URL="https://your-server-url"
Configuration Precedence
The SDK uses the following precedence order for configuration (highest to lowest):
- Explicitly passed configuration in code.
- Environment variables.
- Configuration file.
- Default values.