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.
- Navigate to the Daytona Dashboard.
- Go to API Keys.
- Click the
Create Key
button. - Add your API key to your
.env
file by setting theDAYTONA_API_KEY
environment variable. - Define the Daytona server URL in your
.env
file by setting theDAYTONA_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 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="us")
import { DaytonaConfig } from '@daytonaio/sdk';
const config: DaytonaConfig = { apiKey: "your-api-key", serverUrl: "your-server-url", target: "us"};
Environment Variables
Daytona SDK supports environment variables for configuration. The SDK automatically looks for these environment variables:
Variable | Description | Optional |
---|---|---|
DAYTONA_API_KEY | Your Daytona API key. | |
DAYTONA_SERVER_URL | URL of your Daytona server. | Yes |
DAYTONA_TARGET | Daytona 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:
DAYTONA_API_KEY=your-api-keyDAYTONA_SERVER_URL=https://your-server-urlDAYTONA_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:
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.