> ## Documentation Index
> Fetch the complete documentation index at: https://docs.riza.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Hello, World!

> Executing your first script with Riza

The Riza Code Interpreter API allows you to safely execute untrusted [Python](/interpreters/python),
[JavaScript](/interpreters/javascript), [Ruby](/interpreters/ruby) or [PHP](/interpreters/php) in an isolated and secure sandbox, powered by
[WebAssembly](https://webassembly.org/).

## Install a Client Library

We publish API client libraries for
[Python](https://github.com/riza-io/riza-api-python),
[Node](https://github.com/riza-io/riza-api-node) and
[Go](https://github.com/riza-io/riza-api-go). We'll use them for this example.

<CodeGroup>
  ```bash npm theme={null}
  $ npm install @riza-io/api
  ```

  ```bash pip theme={null}
  $ pip install rizaio
  ```

  ```bash go get theme={null}
  $ go get github.com/riza-io/riza-api-go
  ```
</CodeGroup>

## Get an API Key

All requests to the Riza API require authentication. You can get an API key from
the [Riza Dashboard](https://dashboard.riza.io).

Once you have an API key, set it as the value of an environment variable named
`RIZA_API_KEY`.

```bash theme={null}
export RIZA_API_KEY="<api-key-contents>"
```

## Say "Hello"

Let's write a simple script that prints "Hello, world!" using our [Execute Code API](/api-reference/command/execute-code).
We'll use Python for this example, but our Code Interpreter API also supports
JavaScript, TypeScript, Ruby and PHP.

```python theme={null}
print('Hello, world!')
```

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.

<CodeGroup>
  ```js Node theme={null}
  import Riza from "@riza-io/api";

  const riza = new Riza();

  async function main() {
    const resp = await riza.command.exec({
      language: "python",
      code: "print('Hello, world!')",
    });
    console.log(resp.stdout);
  }

  main();
  ```

  ```py Python theme={null}
  from rizaio import Riza

  client = Riza()

  resp = client.command.exec(
      language="python",
      code="print('Hello, world!')",
  )

  print(resp.stdout)
  ```

  ```go Go theme={null}
  package main

  import (
      "context"
      "log"

      "github.com/riza-io/riza-api-go"
  )

  func main() {
      client := riza.NewClient()
      resp, err := client.Command.Exec(context.Background(), riza.CommandExecParams{
          Language: riza.F(riza.CommandExecParamsLanguagePython),
          Code:     riza.F("print('Hello, world!')"),
      })
      if err != nil {
          log.Fatal(err)
      }
      log.Println(resp.Stdout)
  }
  ```

  ```bash curl theme={null}
  curl https://api.riza.io/v1/execute \
  -H "Authorization: Bearer $RIZA_API_KEY" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data-binary @- << EOF
  {
      "language": "python",
      "code": "print('Hello, world!')"
  }
  EOF
  ```
</CodeGroup>

Each example above should print `Hello, world!` to standard output. The API response will look like this:

```json theme={null}
{
  "exit_code": 0,
  "stdout": "Hello, world!\n",
  "stderr": ""
}
```

## 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](/api-reference/command/execute-function).

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}`:

```python theme={null}
def execute(input):
    print(f"Hello, {input['name']}!")
    return {"name": input["name"], "greeted": True}
```

Here's how we'd make this request to our Execute Function API:

<CodeGroup>
  ```js Node theme={null}
  import Riza from "@riza-io/api";

  const riza = new Riza();

  const code = `
  def execute(input):
      print(f"Hello, {input['name']}!")
      return {"name": input["name"], "greeted": True}
  `;

  async function main() {
    const resp = await riza.command.execFunc({
      language: "python",
      code,
      input: { name: "David" },
    });
    console.log(resp.execution.stdout);
  }

  main();
  ```

  ```py Python theme={null}
  from rizaio import Riza

  client = Riza()

  code = """
  def execute(input):
      print(f"Hello, {input['name']}!")
      return {"name": input["name"], "greeted": True}
  """

  resp = client.command.exec_func(
      language="python",
      code=code,
      input={"name": "David"},
  )

  print(resp.execution.stdout)
  ```

  ```go Go theme={null}
  package main

  import (
      "context"
      "log"

      "github.com/riza-io/riza-api-go"
  )

  func main() {
      client := riza.NewClient()

      code = `
  def execute(input):
      print(f"Hello, {input['name']}!")
      return {"name": input["name"], "greeted": True}
  `

      resp, err := client.Command.ExecFunc(context.Background(), riza.CommandExecFuncParams{
          Language: riza.F(riza.CommandExecFuncParamsLanguagePython),
          Code:     riza.F(code),
          Input:    riza.F(map[string]string{"name": "David"}),
      })
      if err != nil {
          log.Fatal(err)
      }
      log.Println(resp.Execution.Stdout)
  }
  ```

  ```bash curl theme={null}
  curl https://api.riza.io/v1/execute-function \
  -H "Authorization: Bearer $RIZA_API_KEY" \
  -H "Content-Type: application/json; charset=utf-8" \
  --data-binary @- << EOF
  {
      "language": "python",
      "code": "def execute(input):\n    print(f'Hello, {input['name']}!')\n    return {'name': input['name'], 'greeted': True}",
      "input": {"name": "David"}
  }
  EOF
  ```
</CodeGroup>

The response will look like this:

```json theme={null}
{
  "output": { "name": "David", "greeted": true },
  "output_status": "valid",
  "execution": { "exit_code": 0, "stdout": "Hello, David!\n", "stderr": "" }
}
```

## Next Steps

* [Try out the API](https://riza.io/playground).
* See how to [pass input](/reference/input) to your code.
* Learn how to connect the Code Interpreter API to LLMs from [OpenAI](/tool-use/openai), [Anthropic](/tool-use/anthropic) and [Google](/tool-use/gemini).
* Check out the [roadmap](/reference/roadmap) to see what we're working on next.
