Before starting, make sure you have installed the SDK and set up authentication.
Create a sandbox
Sandboxes let you run arbitrary code in isolated, containerized environments. Here’s a simple example that creates a sandbox running thecat command:
- Python
- TypeScript
- Go
sandbox_example.py
Call a deployed function
You can call Modal Functions that have been deployed using the Python SDK. Here’s how to call a function from each SDK:- Python
- TypeScript
- Go
call_function.py
The Python SDK also lets you define functions using the
@app.function() decorator. See the Modal documentation for details.Key concepts
Apps
Apps are containers for your Modal resources. Every sandbox, function, and resource belongs to an app. You can create apps withfrom_name() or reference existing ones.
Images
Images define the runtime environment for your code. You can use pre-built images from Docker registries or build custom images with specific dependencies.Sandboxes
Sandboxes are isolated execution environments where you can run arbitrary commands, execute scripts, and interact with the filesystem. They’re perfect for:- Running untrusted code safely
- Building AI coding agents
- Processing data in isolated environments
- Testing code in different environments
Functions
Functions are Python callables deployed on Modal that you can invoke from any SDK. They automatically handle serialization, execution, and result retrieval.Next steps
Explore examples
Browse example applications and use cases
API reference
Dive into the complete API documentation
User guide
Learn best practices and advanced features
Join the community
Get help and share your projects on Slack