SandboxFusion-compatible API
A hosted endpoint in the shape of SandboxFusion's run_code, at https://api.onlinecompiler.io/api/sandboxfusion/run_code, for training and evaluation tools that grade generated code: the same request and answer, with your API key, and no sandbox server of your own.
Tools written for a SandboxFusion server work here with two changes: point their run_code URL at https://api.onlinecompiler.io/api/sandboxfusion/run_code, and send your API key in the Authorization header, bare or after Bearer. The request and the answer keep SandboxFusion's fields.
/api/sandboxfusion/run_codecurl -X POST https://api.onlinecompiler.io/api/sandboxfusion/run_code \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "print(sum(map(int, input().split())))",
"language": "python",
"stdin": "1 2",
"run_timeout": 5
}'Response (200)
{
"status": "Success",
"message": "",
"compile_result": null,
"run_result": {
"status": "Finished",
"execution_time": 0.03,
"return_code": 0,
"stdout": "3\n",
"stderr": ""
},
"executor_pod_name": null,
"files": {}
}status is Success when the program exits with 0, and Failed for a non-zero exit, a compile error, the time limit (with run_result.status TimeLimitExceeded) or an output or process limit. SandboxError, with run_result.status Error and the reason in message, means the sandbox failed on our side; such a run is not charged.
Languages
language | Runs on |
|---|---|
python | Python 3.14 |
cpp | C++ G++ 15 |
nodejs | JavaScript Node.js 24 |
go | Go 1.26 |
java | Java OpenJDK 25 |
php | PHP 8.5 |
csharp | C# .NET SDK 10 |
bash | Bash 5.2 |
typescript | TypeScript Deno |
sql | SQL SQLite 3 |
rust | Rust 1.93 |
lua | Lua 5.5 |
R | R 4.6 |
perl | Perl 5.44 |
ruby | Ruby 4.0 |
scala | Scala 3.10 |
julia | Julia 1.13 |
swift | Swift 6.4 |
racket | Racket 9.3 |
pytest | Python 3.14 with pytest: the code is written to test_solution.py and its tests are run |
SandboxFusion's other modes (jest, junit, go_test, D_ut, kotlin_script, and the GPU, Verilog and Lean ones) answer 400 with the list above. Languages run on the versions shown, which can be newer than a SandboxFusion image's.
Differences from SandboxFusion
- Refusals are HTTP errors with
{"error": "..."}, where a SandboxFusion server answers 200: 400 for a bad request, 403 for a missing or wrong key, and 429 when a plan limit is reached or every sandbox is busy, with aRetry-Afterheader whenever waiting helps. run_timeoutis 10 seconds when not sent, as on SandboxFusion, and at most 30 seconds: a longer one runs for 30. Compiling does not count, and Java OpenJDK 25 (1 s), Groovy 6.0 (1.5 s) and F# .NET SDK 10 (2.5 s) get a start-up allowance on top.compile_timeoutis accepted and ignored.memory_limit_MB, when above 0, is the run's memory limit, from 16 MB to your plan's ceiling (512 MB, or up to 2048 MB on Pro and above);-1or no value gives 512 MB.files(paths to base64 content) are written beside the program under the input file limits: up to 20 files and 1 MB in total; anullentry is skipped.fetch_filesis accepted, andfilesin the answer is always{}.- There is no separate compile stage:
compile_resultisnull, and compiler errors arrive inrun_result.stderrwith a non-zeroreturn_code. stdoutandstderrare cut at 64 KB each.- Other fields, such as an
expected_stdouta tool compares itself, are ignored, as SandboxFusion ignores them.
Using it from a tool
- Point the tool's SandboxFusion URL at
https://api.onlinecompiler.io/api/sandboxfusion/run_code, or its base URL athttps://api.onlinecompiler.io/api/sandboxfusionif it adds/run_codeitself, and give it your key for theAuthorizationheader. A tool that takes only a URL and sends no headers needs a header option before it can use a key. - Keep its concurrency at or under your plan's runs at once (4 on Free, 8 on Starter, 10 on Pro, 20 on Business and 100 on Platform), and pick a plan whose runs a minute and a month cover a training step or an eval run: see limits.
- One request is one run: a tool that sends one request per test case uses one run per test.
Questions
- Is this SandboxFusion itself?
- No. It is OnlineCompiler.io's own runner answering in the shape of SandboxFusion's run_code, so a tool written for a SandboxFusion server needs only a new URL and an API key. Every run gets a fresh gVisor sandbox with no network access, deleted afterwards. OnlineCompiler.io is not affiliated with ByteDance, which publishes SandboxFusion.
- What does a call cost?
- Each call is one run of your plan's monthly runs, as on run-code, whatever its language, pytest included. A run that fails on our side (status "SandboxError") is not charged.
- How many calls can run at once?
- Your plan's runs at once: 4 on Free, 8 on Starter, 10 on Pro, 20 on Business and 100 on Platform. Set the tool's concurrency at or under that number; calls above it answer 429 with a Retry-After header.
- Can I get files back?
- Not on this endpoint yet: fetch_files is accepted, and files in the answer is always empty. The run endpoints return files a program writes to $OUTPUT_DIR.