We support custom runtimes for Python and JavaScript.

Custom runtimes allow you to install dependencies for use in your Python and JavaScript code. After building a custom runtime, you can use it with the Execute Code endpoint.

You can create custom runtimes from the Riza Dashboard, but in this guide, we’ll use the Custom Runtimes API to programmatically create and manage custom runtimes.

Set up

Before getting started, you’ll need an API key from the Riza Dashboard. Export it as an environment variable within your shell:

export RIZA_API_KEY=<your-api-key>

Create a Python custom runtime

In this example, we’ll create a custom Riza runtime environment with the Markdown Python package, which converts Markdown to HTML.

The required parameters are “name”, “language” and “manifest_file”, which is a simple PyPi requirements file declaring your dependencies.

The resulting runtime object you receive from the API will look like this. Take note of the id and revision_id parameters, which we’ll use in future steps.

{
	'id': '01JFESTGXM...',
	'language': 'python',
	'name': 'acme_corp_custom_runtime',
	'revision_id': '01JFETP2VD...',
	'status': 'pending',
	'additional_python_imports': '',
	'manifest_file': ManifestFile(contents='markdown==3.7', name='requirements.txt')
}

Each custom runtime will have one or more associated revisions. The first revision is automatically created when you create a runtime. You’ll have a new revision_id each time you update your dependencies, while the runtime id will remain the same.

Create a JavaScript custom runtime

In this example, we’ll create a custom Riza JavaScript runtime environment with the marked package.

Wait for the custom runtime to build

Building a custom runtime is not instant. It will likely take a few minutes.

To check a build’s status, use the Riza API to fetch the custom runtime. The runtime object’s status parameter indicates whether the latest build is complete and whether it succeeded or failed.

To monitor progress, periodically call the API until the status is either "succeeded" or "failed". The code below demonstrates this approach.

Use the custom runtime

If the custom runtime build succeeds, you can now use it to run code that imports the Markdown package.

You’ll need the runtime revision ID from the first step to use the runtime with the Execute Code endpoint.

Now, you can execute Python code with the markdown package using the custom runtime from the previous step.

Similarly, you can execute JavaScript code with the marked package using the custom runtime from the previous step.

Next steps

Check out the Create Runtime Revision endpoint if you need to add or remove dependencies.

If you have questions, please drop us a line in Discord.