interface ModalSandboxOptionsBaseSdkOptionsConfiguration options for creating a Modal Sandbox.
Extends the Modal SDK's SandboxCreateParams with additional options for app/image configuration and a simplified volumes/secrets API.
Name of the Modal App to associate the sandbox with. If not provided, a default app name will be used. The app will be created if it doesn't exist.
Docker image to use for the sandbox container. Can be any public Docker image or a Modal Image reference.
Initial files to populate the sandbox with.
Keys are file paths (relative to the working directory), values are file contents. Parent directories will be created automatically if they don't exist.
Error name for instanceof checks and logging
Modal Secret names to inject into the sandbox environment. Secrets must be created beforehand in Modal.
Unlike the SDK which requires Secret objects, we accept secret names and look them up automatically.
Modal Volume names to mount, mapped to their mount paths. Volumes must be created beforehand in Modal.
Unlike the SDK which requires Volume objects, we accept volume names and look them up automatically.
Authentication configuration for Modal API.
# Create a token at https://modal.com/settings/tokens
export MODAL_TOKEN_ID=your_token_id
export MODAL_TOKEN_SECRET=your_token_secret
Or pass the credentials directly in this auth configuration.
const options: ModalSandboxOptions = {
appName: "my-sandbox-app",
imageName: "python:3.12-slim",
timeoutMs: 600_000, // 10 minutes
memoryMiB: 2048, // 2GB
initialFiles: {
"/app/index.js": "console.log('Hello')",
},
};// Use Python image
imageName: "python:3.12-slim"
// Use Node.js image
imageName: "node:20-slim"initialFiles: {
"/src/index.js": "console.log('Hello')",
"/package.json": '{"name": "my-app"}',
}secrets: ["my-api-keys", "database-credentials"]volumes: {
"/data": "my-data-volume",
"/cache": "my-cache-volume"
}