Code Execution

Secure multi-language code execution engine with 50+ languages, Linux namespace isolation, and configurable resource limits.

What is Code Execution?

Code Execution lets your AI agents run scripts in 50+ programming languages with a single API call. It is designed for quick, stateless computations — data transformations, format conversions, calculations, and validation logic.

Under the hood, Transactional runs a self-hosted Piston engine with Linux namespace isolation to securely execute untrusted code.

Key Features

  • 50+ languages — Python, JavaScript, TypeScript, Go, Rust, Ruby, Java, C, C++, and many more
  • Fast execution — Pre-warmed language runtimes for near-instant starts
  • Secure isolation — Linux namespace and cgroup isolation per execution
  • Configurable limits — Set time and memory caps per request
  • Stdin/stdout — Pass input data and capture output programmatically
  • No infrastructure — No VMs to manage, no containers to orchestrate

When to Use Code Execution

Code Execution is ideal for quick, stateless tasks:

Use CaseExample
Data transformationParse CSV, convert JSON, format output
CalculationsMath operations, statistical analysis
ValidationCheck data formats, validate schemas
Code generation testingRun LLM-generated code safely
Multi-language tasksUse the best language for each sub-task

For long-running processes, package installation, or stateful workflows, use Sandboxes instead.

Code Execution vs. Sandboxes

Code ExecutionSandboxes
StartupInstant (pre-warmed)~200ms (microVM boot)
StateStateless (no filesystem persistence)Full stateful environment
Languages50+ languagesPython, Node, Deno
PackagesStandard library onlyInstall any package
DurationMax 30 secondsUp to 1 hour
Use caseQuick scriptsComplex workflows
PricingPer executionPer second of uptime

How It Works

Your Agent
    |
    v
tx.code.run({ language: 'python', code: '...' })
    |
    v
+---------------------------+
|  Piston Engine             |
|  - Linux namespace         |
|  - cgroup resource limits  |
|  - Pre-warmed runtimes     |
|  - Stdout/stderr capture   |
+---------------------------+
    |
    v
{ stdout, stderr, exitCode, executionTime }
  1. Submit — Send code and language to the API
  2. Execute — Piston runs the code in an isolated namespace
  3. Return — Stdout, stderr, exit code, and execution time are returned

Resource Limits

ResourceDefaultMaximum
Execution time10 seconds30 seconds
Memory128 MB512 MB
Output size1 MB5 MB
File writesDisabledDisabled
NetworkDisabledDisabled

Security Model

Each execution is isolated using Linux kernel features:

  • Namespaces — Separate PID, network, mount, and user namespaces per execution
  • Cgroups — Hard limits on CPU time, memory, and processes
  • No network — Executions cannot make outbound network requests
  • No filesystem persistence — All writes are discarded after execution
  • Process limits — Maximum number of spawned processes is capped

Pricing

TierRateIncludes
Free$01,000 executions/month
Pro$0.001/execution10,000 executions/month included
EnterpriseCustomVolume discounts available

Next Steps