modal-ts
    Preparing search index...

    modal-ts

    modal-ts

    日本語

    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-...
    • Functions - Call deployed Modal functions and classes
    • Sandboxes - Create and manage sandboxes with exec, stdin/stdout, tunnels, filesystem access
    • Queues - Distributed FIFO queues with partition support
    • Volumes - Persistent storage
    • Images - Build container images from registries, Dockerfiles, ECR, GCP Artifact Registry
    • Secrets - Manage environment secrets
    • Deploy - Deploy apps, functions, and classes via gRPC API
    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:

    • TypeScript-only - Go SDK removed
    • No Python dependency - Test infrastructure and release scripts rewritten in TypeScript
    • Bun - Uses Bun instead of npm
    • Biome - Uses Biome instead of ESLint + Prettier
    • Strict TypeScript - verbatimModuleSyntax, noUncheckedIndexedAccess, exactOptionalPropertyTypes enabled. No any, no @ts- directives
    • esbuild - Direct esbuild instead of tsup

    Apache-2.0. Proto definitions from modal-labs/modal-client (Apache-2.0).