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 Case | Example |
|---|---|
| Data transformation | Parse CSV, convert JSON, format output |
| Calculations | Math operations, statistical analysis |
| Validation | Check data formats, validate schemas |
| Code generation testing | Run LLM-generated code safely |
| Multi-language tasks | Use the best language for each sub-task |
For long-running processes, package installation, or stateful workflows, use Sandboxes instead.
Code Execution vs. Sandboxes
| Code Execution | Sandboxes | |
|---|---|---|
| Startup | Instant (pre-warmed) | ~200ms (microVM boot) |
| State | Stateless (no filesystem persistence) | Full stateful environment |
| Languages | 50+ languages | Python, Node, Deno |
| Packages | Standard library only | Install any package |
| Duration | Max 30 seconds | Up to 1 hour |
| Use case | Quick scripts | Complex workflows |
| Pricing | Per execution | Per 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 }
- Submit — Send code and language to the API
- Execute — Piston runs the code in an isolated namespace
- Return — Stdout, stderr, exit code, and execution time are returned
Resource Limits
| Resource | Default | Maximum |
|---|---|---|
| Execution time | 10 seconds | 30 seconds |
| Memory | 128 MB | 512 MB |
| Output size | 1 MB | 5 MB |
| File writes | Disabled | Disabled |
| Network | Disabled | Disabled |
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
| Tier | Rate | Includes |
|---|---|---|
| Free | $0 | 1,000 executions/month |
| Pro | $0.001/execution | 10,000 executions/month included |
| Enterprise | Custom | Volume discounts available |
Next Steps
- Quickstart — Run your first script
- Languages — Full list of supported languages
- Architecture — How Code Execution fits into the agent platform