as-...) is the API key and the token id
(ak-...) is stored as token_id. Calls run in the account’s default
environment unless an operation gets environment, or the plugin is set up
with modal({ environment: 'dev' }).
- Modal has no REST API. Everything goes over gRPC through Modal’s
official JavaScript SDK, so the plugin runs on Node (HTTP/2), not in edge
or browser runtimes. The SDK loads the first time an operation runs; each
call makes its own client from the account’s tokens and closes it after.
The host’s
MODAL_TOKEN_ID,MODAL_TOKEN_SECRET,MODAL_ENVIRONMENTand~/.modal.tomlare never used for an account. - Money. Sandboxes, image builds and function calls are billed per
second of CPU, memory and GPU.
sandboxes.create,sandboxes.exec,sandboxes.resume,sandboxes.restoreSnapshot,images.build,functions.call,functions.spawn,classes.*andfunctions.updateAutoscaleraredestructive, as is every delete, stop, clear and cancel. A sandbox ends at itstimeoutMs(Modal’s default is 5 minutes) or withsandboxes.terminate. - Sandboxes belong to an App;
sandboxes.createusescorsair-sandboxes(created if missing) unlessappNameis given, and the registry imagepython:3.13-slimunlessimageis given. Ports inencryptedPorts,h2PortsorunencryptedPortscome back as tunnel URLs.sandboxes.execwaits for the command and returns its exit code, stdout and stderr (each capped atmaxOutputBytes, 1 MB by default). - Functions and classes have to be deployed with Modal’s Python CLI
first (
modal deploy); the plugin looks them up by App and name. Arguments go CBOR-encoded, which Modal 1.2+ deployments accept.functions.callwaits up towaitMsand returns statuspendingwith afunctionCallIdif the call is still running;functionCalls.getpicks the result up later. - Queues and dicts store Python pickles, so Python code on Modal reads
what the plugin writes. Dict keys are strings, numbers, booleans or null,
encoded byte for byte as Python does, so the same key matches from both
sides. Integers keep their full value, Python tuples and sets come back as
arrays, bytes as
{ "$bytes": "<base64>" }(send the same shape to store bytes), and objects JSON has no form for (datetimes, class instances) as{ "$pickle": "<base64>" }. - Lists of volumes, secrets, queues and dicts page newest first: pass the
returned
nextCreatedBeforeascreatedBefore. - Not wrapped: deploying Apps (Python CLI only), web endpoint URLs you call
yourself, the SDK’s experimental sidecar containers and outbound header
policies, and reading or uploading Volume files (mount the Volume in a
sandbox and use
files.*).
- 95 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
Store the Modal API key before the first call: More: API Key
pnpm corsair setup --plugin=modal --tenant=acme api_key=<your-key> (leave out --tenant without multiTenancy), or pass it as key in the plugin options. With Hub, each tenant enters their own key on the connect page. See API key auth.4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List running sandboxesWhat’s next
API reference
Every
modal.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.