Hello, World!
Executing your first script with Riza
The Riza Code Interpreter API allows you to safely execute untrusted Python, JavaScript, Ruby or PHP in an isolated and secure sandbox, powered by WebAssembly.
Install a Client Library
We publish API client libraries for Python, Node and Go. We’ll use them for this example.
Get an API Key
All requests to the Riza API require authentication. You can get an API key from the Riza Dashboard.
Once you have an API key, set it as the value of an environment variable named
RIZA_API_KEY
.
Say “Hello”
Let’s write a simple script that prints “Hello, world!” using our Execute Code API. We’ll use Python for this example, but our Code Interpreter API also supports JavaScript, TypeScript, Ruby and PHP.
We’ll send this single-line Python script to the Riza API for execution, and print
the output. The only required parameters are language
and code
.
You can use one of our published API client libraries to make this request from
Node, Python or Go, or use curl
if available in your shell.
Each example above should print Hello, world!
to standard output. The API response will look like this:
Execute a function and return a value
In our previous example, we executed a script as you might do in a shell. The only way to get a value back from the script is to print it to standard output as a string.
That’s a good start, but what if we want to return a value from a function? For this, we can use our Execute Function API.
This API supports Python, JavaScript, and TypeScript. It requires you to write your code in a specific way, with a function execute
that takes a single argument input
.
Your function must also return a value that can be serialized to JSON.
Let’s write a simple function that prints “Hello, David!” and returns {"greeted": true}
:
Here’s how we’d make this request to our Execute Function API:
The response will look like this:
Next Steps
- Try out the API.
- See how to pass input to your code.
- Learn how to connect the Code Interpreter API to LLMs from OpenAI, Anthropic and Google.
- Check out the roadmap to see what we’re working on next.