> ## 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.

# Self-hosted Riza Quickstart

> Learn how to deploy the Riza Code Interpreter in your environment

For most customers, our hosted [Code Interpreter API](/introduction) offers the
best solution to safely execute untrusted [Python](/interpreters/python),
[JavaScript](/interpreters/javascript), [Ruby](/interpreters/ruby) or
[PHP](/interpreters/php) in an isolated and secure environment, powered by
[WebAssembly](https://webassembly.org/).

However, you may want to deploy the Code Interpreter API into your network for
security, compliance, or performance reasons.

Unlike other code interpreter solutions, the Riza Code Interpreter is easy to
deploy. It's distributed as a stateless, horizontally scalable service using a
single Docker image, with easy-to-meet system requirements.

* The container **does not** require [privileged mode](https://stackoverflow.com/questions/75296630/what-does-the-docker-exec-privileged-flag-do).
* The container **does not** require specialized instances types, such as AWS `metal` instances.

## Running the service

The **rizaio/code-interpreter** image supports Linux AMD64 and ARM64/v8.

```sh theme={null}
$ docker pull rizaio/code-interpreter
```

Running the service requires a license key.

```sh theme={null}
$ docker run --rm -p3003:3003 -it rizaio/code-interpreter
-----> Validating license key...
       ERROR: The 'RIZA_LICENSE_KEY' environment variable is not set
```

### Obtaining a license key

<Tip>Please reach out to [hello@riza.io](mailto:hello@riza.io) to get a trial license.</Tip>

Once you've obtained a license key, add it to the environment as the value of the
`RIZA_LICENSE_KEY` environment variable.

```sh theme={null}
$ docker run -p3003:3003 -e RIZA_LICENSE_KEY=riza_license_xxx --rm -it rizaio/code-interpreter
-----> Validating license key...
       License key provided via 'RIZA_LICENSE_KEY' environment variable
       Success.

-----> Loading Python (cached)

-----> Loading JavaScript / TypeScript (cached)

-----> Listening on 0.0.0.0:3003
```

The port can be configured using the `PORT` environment variable.

### Using the API

The self-hosted Code Interpreter API is a drop-in replacement for our hosted
API.

Our [client libraries](/guides/client-libraries) support self-hosted instances
by setting the base URL of the client. When running locally, this will default
to `http://localhost:3003`.

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

  const riza = new Riza({
      baseURL: "http://localhost:3003",
      apiKey: "riza_self_hosted",
  });

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

  main();
  ```

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

  client = Riza(
      base_url="http://localhost:3003",
      api_key="riza_self_hosted",
  )

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

  print(dict(resp))
  ```

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

  import (
  	"context"
  	"log"
  	"log/slog"

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

  func main() {
  	client := riza.NewClient(
          option.WithAPIKey("My API Key"),
          option.WithBaseURL("http://localhost:3003"),
      )
  	params := riza.CommandExecParams{
          Language: riza.F(riza.CommandExecParamsLanguagePython),
          Code:     riza.F("print('Hello, self-hosting!')"),
  	}
  	resp, err := client.Command.Exec(context.Background(), params)
  	if err != nil {
  		log.Fatal(err)
  	}
  	slog.Info(
  		resp.Stdout,
  		"code", resp.ExitCode,
  		"stderr", resp.Stderr,
  	)
  }
  ```
</CodeGroup>
