Benchmarked
Modal
Last updated
Was this helpful?
Was this helpful?
npm install @computesdk/modalMODAL_TOKEN_ID=your_modal_token_id
MODAL_TOKEN_SECRET=your_modal_token_secretimport { modal } from '@computesdk/modal';
const compute = modal({
tokenId: process.env.MODAL_TOKEN_ID,
tokenSecret: process.env.MODAL_TOKEN_SECRET,
});
// Create sandbox
const sandbox = await compute.sandbox.create();
// Run a command
const result = await sandbox.runCommand('echo "Hello from Modal!"');
console.log(result.stdout); // "Hello from Modal!"
// Clean up
await sandbox.destroy();interface ModalConfig {
/** Modal token ID - if not provided, will use MODAL_TOKEN_ID env var */
tokenId?: string;
/** Modal token secret - if not provided, will use MODAL_TOKEN_SECRET env var */
tokenSecret?: string;
/** Execution timeout in milliseconds */
timeout?: number;
/** Modal environment (sandbox or main) */
environment?: string;
/** Ports to expose (unencrypted by default) */
ports?: number[];
/** Port for the daemon SSE channel (defaults to 38989); set false to disable */
daemonSsePort?: number | false;
/** Modal app name (default: 'computesdk-modal') */
appName?: string;
/** Use Modal's experimental scalable sandboxes API */
scalableSandboxes?: boolean;
}