Skip to main content
Use Modal through Corsair: one client, typed API calls. Connect a Modal account with a token pair from modal.com, Settings, API Tokens: the token secret (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_ENVIRONMENT and ~/.modal.toml are 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.* and functions.updateAutoscaler are destructive, as is every delete, stop, clear and cancel. A sandbox ends at its timeoutMs (Modal’s default is 5 minutes) or with sandboxes.terminate.
  • Sandboxes belong to an App; sandboxes.create uses corsair-sandboxes (created if missing) unless appName is given, and the registry image python:3.13-slim unless image is given. Ports in encryptedPorts, h2Ports or unencryptedPorts come back as tunnel URLs. sandboxes.exec waits for the command and returns its exit code, stdout and stderr (each capped at maxOutputBytes, 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.call waits up to waitMs and returns status pending with a functionCallId if the call is still running; functionCalls.get picks 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 nextCreatedBefore as createdBefore.
  • 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.*).
What you get:
  • 95 typed API operations

Setup

1

Install

2

Add the plugin

corsair.ts
With multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.
3

Choose authentication

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 sandboxes
Run a command in a sandbox
See the full list on the API page.

What’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.