Key features
Modal’s Python SDK offers powerful capabilities for running code in the cloud:- Serverless functions: Deploy Python functions that scale automatically
- Container orchestration: Run code in custom container environments
- GPU support: Access GPUs for machine learning workloads
- Persistent storage: Use volumes, dicts, and queues for data persistence
- Web endpoints: Create HTTP endpoints with FastAPI, ASGI, or WSGI
- Scheduled jobs: Run functions on cron schedules or periodic intervals
- Async support: Full support for async/await patterns
Python version support
The Modal SDK requires Python 3.10 through 3.14. The SDK will raise a runtime error if you attempt to use it with unsupported Python versions. Frommodal/__init__.py:4-7:
Core concepts
Apps
AnApp is the main entry point for defining Modal applications. Apps contain functions, classes, and other resources:
Functions
Functions are the primary way to run code on Modal. Decorate any Python function with@app.function() to run it in the cloud:
Images
Images define the container environment for your functions. Modal provides pre-built images and supports custom configurations:Resources
Modal provides several resource types for data persistence and communication:- Volume: Persistent file storage across function invocations
- Dict: Key-value store for structured data
- Queue: FIFO queue for task distribution
- Secret: Secure storage for API keys and credentials
- NetworkFileSystem: Shared file system for concurrent access
Available exports
The Modal SDK exports the following classes and functions (frommodal/__init__.py:57-99):
Core classes:
App- Main application containerClient- Low-level API clientFunction,FunctionCall- Function primitivesImage- Container image builder
Cls- Parameterized classesSandbox,SandboxSnapshot- Interactive environments
Volume- Persistent volumesDict- Distributed dictionariesQueue- Distributed queuesNetworkFileSystem- Network file systemsCloudBucketMount- Cloud storage mounting
Secret- Secure credentialsRetries- Retry policiesCron,Period- SchedulingSchedulerPlacement- Placement constraints
web_endpoint- HTTP endpointsfastapi_endpoint- FastAPI integrationasgi_app,wsgi_app- ASGI/WSGI appsbatched- Batch processingconcurrent- Concurrent execution
is_local()- Check execution contextcurrent_input_id(),current_function_call_id()- Runtime contextinteract()- Interactive debuggingforward()- Port forwarding
Next steps
Installation
Install the Modal Python SDK with pip, uv, or poetry
Basic usage
Learn basic patterns for running functions on Modal
Async support
Use async/await with Modal functions
CLI reference
Explore Modal’s command-line interface