Creating a client
All interactions with Modal start with creating aModalClient instance:
modal.apps- App managementmodal.sandboxes- Sandbox creation and managementmodal.functions- Function callingmodal.cls- Class callingmodal.images- Image buildingmodal.volumes- Volume managementmodal.queues- Queue operationsmodal.secrets- Secret managementmodal.proxies- Proxy management
Working with sandboxes
Sandboxes are isolated execution environments where you can run arbitrary code.Create and run a sandbox
Execute commands in a sandbox
Use named sandboxes
Create a sandbox with a name to reference it later:Calling functions
Call Modal Functions that are deployed with the Python SDK.Basic function call
Spawn functions asynchronously
Spawn a function without waiting for the result:Working with classes
Call methods on Modal class instances.Basic class usage
Override class options
You can override concurrency, batching, and other options:Building images
Create custom images from registries or with Dockerfile commands.From a registry
- Docker Hub
- AWS ECR
- GCP Artifact Registry
Add Dockerfile commands
Working with volumes
Volumes provide persistent storage across sandbox runs.Create and mount a volume
Use ephemeral volumes
Create temporary volumes that exist only for the duration of use:Using secrets
Secrets provide secure environment variables to sandboxes.From Modal secrets
From object
Create secrets from key-value pairs:Working with queues
Queues allow communication between different parts of your application.Create and use a queue
Iterate over queue items
Error handling
The SDK provides specific error types for different failure scenarios:Resource cleanup
Always clean up resources when you’re done:Next steps
Client configuration
Learn about advanced client configuration
API reference
Explore the full API documentation