Unofficial Modal SDK for TypeScript/JavaScript. Forked from modal-labs/libmodal (Apache-2.0).
npm install modal-ts
import { ModalClient } from "modal-ts";
const modal = new ModalClient();
// Call a deployed function
const echo = await modal.functions.fromName("my-app", "echo");
const result = await echo.remote(["Hello world!"]);
console.log(result);
// Run a sandbox
const app = await modal.apps.fromName("my-app", { createIfMissing: true });
const image = modal.images.fromRegistry("alpine:3.21");
const sb = await modal.sandboxes.create(app, image, { command: ["echo", "hi"] });
console.log(await sb.stdout.readText());
await sb.terminate();
Set environment variables or configure ~/.modal.toml:
export MODAL_TOKEN_ID=ak-...
export MODAL_TOKEN_SECRET=as-...
bun install # Install deps + generate proto
bun run typecheck # Type check
bun run lint # Biome lint
bun run format # Biome format
bun run build # Build (esbuild + tsc)
bun run test # Run tests (vitest)
This fork diverges from modal-labs/libmodal:
verbatimModuleSyntax, noUncheckedIndexedAccess, exactOptionalPropertyTypes enabled. No any, no @ts- directivesApache-2.0. Proto definitions from modal-labs/modal-client (Apache-2.0).