@tpmjs/unsandbox
Execute code synchronously in a secure sandbox. Supports 42+ languages including python, javascript, typescript, go, rust, c, cpp, java, ruby, and more. Returns stdout, stderr, and exit code.
This tool was automatically discovered from the package exports. The author did not explicitly register it in their package.json. Schema and description were auto-extracted.
Test @tpmjs/unsandbox (executeCode) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/unsandboxpnpm add @tpmjs/unsandboxyarn add @tpmjs/unsandboxbun add @tpmjs/unsandboxdeno add npm:@tpmjs/unsandboximport { executeCode } from '@tpmjs/unsandbox';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { executeCode } from '@tpmjs/unsandbox';
const result = await generateText({
model: openai('gpt-4o'),
tools: { executeCode },
prompt: 'Your prompt here...',
});
console.log(result.text);(code: string, language: string, ttl?: number, input_files?: { content: string; filename: string }[], network_mode?: string, return_artifact?: boolean, return_wasm_artifact?: boolean) => Promise<unknown>Available configuration options
languagestringProgramming language to execute. Supported: python, javascript, typescript, ruby, perl, php, lua, bash, r, elixir, erlang, tcl, scheme, powershell, clojure, commonlisp, crystal, groovy, deno, awk, raku, c, cpp, go, rust, java, kotlin, cobol, fortran, d, zig, nim, v, objc, dart, julia, haskell, ocaml, fsharp, csharp, prolog, forth. Aliases: node/js -> javascript, ts -> typescript, lisp -> commonlisp.
codestringThe source code to execute.
input_filesarrayOptional array of input files to make available in /tmp/input/. Each file needs filename and base64-encoded content.
network_modestringNetwork isolation mode. "zerotrust" (default) blocks all network access. "semitrusted" allows outbound connections.
ttlnumberExecution timeout in seconds (1-900). Default: 60.
return_artifactbooleanFor compiled languages, return the compiled binary as base64.
return_wasm_artifactbooleanCompile to WebAssembly and return as base64. Supported for C, C++, Rust, Zig, Go.
Schema extracted: 3/1/2026, 4:28:06 AM
AI SDK tools for secure code execution in 42+ programming languages via unsandbox.com.
npm install @tpmjs/unsandbox # or pnpm add @tpmjs/unsandbox
Get an API key at unsandbox.com/api-keys and set it as an environment variable:
export UNSANDBOX_API_KEY=your-api-key
import { streamText } from 'ai'; import { anthropic } from '@ai-sdk/anthropic'; import { executeCode, listLanguages } from '@tpmjs/unsandbox'; const result = streamText({ model: anthropic('claude-sonnet-4-20250514'), tools: { executeCode, listLanguages, }, system: 'You can execute code in 42+ programming languages using a secure sandbox.', prompt: 'Write and run a Python script that calculates the first 10 Fibonacci numbers', });
Execute code synchronously in a secure sandbox.
import { executeCode } from '@tpmjs/unsandbox'; const result = await executeCode.execute({ language: 'python', code: 'print("Hello, World!")', }); // { stdout: "Hello, World!\n", stderr: "", exit_code: 0 }
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
language | string | Yes | Programming language (python, javascript, go, rust, etc.) |
code | string | Yes | Source code to execute |
input_files | array | No | Files to make available in /tmp/input/ |
network_mode | string | No | 'zerotrust' (default) or 'semitrusted' |
ttl | number | No | Timeout in seconds (1-900, default 60) |
return_artifact | boolean | No | Return compiled binary for compiled languages |
return_wasm_artifact | boolean | No | Compile to WebAssembly (C, C++, Rust, Zig, Go) |
Execute code asynchronously, returning a job_id for tracking.
import { executeCodeAsync, getJob } from '@tpmjs/unsandbox'; const job = await executeCodeAsync.execute({ language: 'rust', code: 'fn main() { println!("Hello from Rust!"); }', }); // Check status later const result = await getJob.execute({ job_id: job.job_id });
Execute code with automatic language detection from shebang.
import { runCode } from '@tpmjs/unsandbox'; const result = await runCode.execute({ code: `#!/usr/bin/env python3 print("Auto-detected Python!")`, });
Async version of runCode.
List all active jobs for your API key.
import { listJobs } from '@tpmjs/unsandbox'; const jobs = await listJobs.execute({});
Get status and results of a specific async job.
import { getJob } from '@tpmjs/unsandbox'; const result = await getJob.execute({ job_id: 'abc123' }); // { status: 'completed', stdout: '...', stderr: '...' }
Cancel a running or pending async job.
import { cancelJob } from '@tpmjs/unsandbox'; await cancelJob.execute({ job_id: 'abc123' });
List all 42+ supported programming languages.
import { listLanguages } from '@tpmjs/unsandbox'; const languages = await listLanguages.execute({});
42+ languages including:
| Variable | Required | Description |
|---|---|---|
UNSANDBOX_API_KEY | Yes | API key from unsandbox.com |
MIT
Downloads/month
15
GitHub Stars
0
Quality Score