The Code Interpreter API lets you execute untrusted code in a few lines of code.

But how do we actually safely execute that code? Here’s a brief explanation of how it works.

1

Receive request

Your application makes a request to https://api.riza.io with the code to execute and any input data.

2

Validate data

We validate that the incoming code and data don’t violate resource limits.

3

Load WebAssembly

We load the compiled WebAssembly binary for the selected interpreter into memory. For most requests this step is cached.

4

Create WebAssembly module

We instantiate a new WebAssembly module for the loaded interpreter. We set stdin, command line arguments and environment variables, and configure runtime resource limits.

5

Execute code

We execute the code from your request within the WebAssembly module.

6

Return response

We return stdout and stderr from the execution, along with the program’s exit code.