import Riza from '@riza-io/api';

// Untrusted Python code, either written by 
// a customer or a LLM.
const python = `
import sys
import os

if 'DEBUG' in os.environ:
    print('Reversing string...', file=sys.stderr)
stdin = sys.stdin.read()
print("".join(reversed(stdin)))
`;

const riza = new Riza();

async function main() {
  const resp = await riza.command.exec({
    language: "python",
    code: python,
    stdin: "Hello", 
    env: {
      "DEBUG": "true",
    }
  });
  console.dir(resp, {depth: null});
}

main();
{
    "exit_code": 0,
    "stdout": "olleH",
    "stderr": "Reversing string..."
}
import Riza from '@riza-io/api';

// Untrusted Python code, either written by 
// a customer or a LLM.
const python = `
import sys
import os

if 'DEBUG' in os.environ:
    print('Reversing string...', file=sys.stderr)
stdin = sys.stdin.read()
print("".join(reversed(stdin)))
`;

const riza = new Riza();

async function main() {
  const resp = await riza.command.exec({
    language: "python",
    code: python,
    stdin: "Hello", 
    env: {
      "DEBUG": "true",
    }
  });
  console.dir(resp, {depth: null});
}

main();
{
    "exit_code": 0,
    "stdout": "olleH",
    "stderr": "Reversing string..."
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
code
string
required

The code to execute.

language
enum<string>
required

The interpreter to use when executing code.

Available options:
python,
javascript,
typescript,
ruby,
php
args
string[]

List of command line arguments to pass to the script.

env
object

Set of key-value pairs to add to the script's execution environment.

files
object[]

List of input files.

http
object

Configuration for HTTP requests and authentication.

limits
object

Configuration for execution environment limits.

runtime_revision_id
string

The ID of the runtime revision to use when executing code.

stdin
string

Input made available to the script via 'stdin'.

Response

OK

duration
integer
required

The execution time of the script in milliseconds.

exit_code
integer
required

The exit code returned by the script. Will often be '0' on success and non-zero on failure.

id
string
required

The ID of the execution.

stderr
string
required

The contents of 'stderr' after executing the script.

stdout
string
required

The contents of 'stdout' after executing the script.