# Otari

> Mozilla.ai's self-hosted AI gateway with virtual keys, budgets and routing policies

- Category: Evaluation & Production Ops / Gateways & Routing
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/mozilla-ai/otari
- Website: https://otari.ai/
- Canonical page: https://ai-tldr.dev/tools/otari/
- Updated: 2026-12-01

## In short

Otari is an open-source AI gateway from Mozilla.ai that you run on your own infrastructure. It sits between your applications and the model providers: it authenticates each request, resolves the provider credentials, enforces budgets before the call is dispatched and records usage afterwards. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Otari is an open-source AI gateway from Mozilla.ai that you run on your own infrastructure. It sits between your applications and the model providers: it authenticates each request, resolves the provider credentials, enforces budgets before the call is dispatched and records usage afterwards. Applications talk to one OpenAI- and Anthropic-compatible endpoint that fronts 40+ providers, and the provider calls themselves go through Mozilla.ai's any-llm library.

Its job is to keep provider keys and spending under the operator's control. Clients get revocable API keys scoped to a user, a workspace and a set of models, so they never see the upstream credentials; budgets are checked before spend and settled after it. A web dashboard manages providers, models, routing, tools, keys, members, budgets, activity and usage, and the running server publishes Swagger UI and an OpenAPI document for its completion and management APIs.

Routing is expressed as policies: a caller-facing model name that resolves to one or more real models, used for failover, conditional selection, weighted traffic splitting and spill-over past a rate limit. Optional services add server-side code execution, web search, MCP, inference guardrails and file understanding. Mozilla.ai announced Otari in May 2026 together with Otari.ai, a hosted platform built on the same engine.

## What it does

- One OpenAI- and Anthropic-compatible endpoint (`/api/v1/chat/completions`, `/api/v1/messages`, `/api/v1/responses`) for 40+ providers
- Revocable virtual API keys scoped by user, workspace and model, with provider credentials kept behind the gateway
- Budget checks before a request is dispatched and usage records after it settles
- Routing policies for failover, conditional selection, weighted traffic splitting and spill-over past a rate limit
- Optional code execution sandbox, web search, MCP, inference guardrails and file understanding
- Dashboard for providers, models, routing, keys, members, budgets, activity and usage, plus a model Playground
- Single Docker container on SQLite, or Docker Compose on PostgreSQL

## Getting started

The README's quickstart runs the whole gateway from one Docker image with no configuration; the Compose setup adds PostgreSQL and the optional services.

1. Start the gateway

   The `otari` volume keeps the SQLite database and the key that encrypts stored provider credentials, so a new container with the same volume keeps its data.

```bash
docker run -v otari:/data -p 127.0.0.1:8000:8000 mzdotai/otari:latest
```

2. Finish setup in the dashboard

   On first start Otari prints a one-time setup link that carries the master key. Open it, choose the email and password you will sign in with, add a provider on the Hosted providers page and enable default pricing there. Then create an API key on the API keys page.

```text
Open this link to choose your password and finish setup:

http://localhost:8000/setup#key=otari-mk-...
```

3. Send a request

   Use the key you created. OpenAI clients work by setting `base_url` to `http://localhost:8000/api/v1`.

```bash
curl http://localhost:8000/api/v1/chat/completions \
  -H "Authorization: Bearer tk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai:gpt-4o-mini",
    "messages": [{"role": "user", "content": "Say hello."}]
  }'
```

4. Add a failover policy

   From the routing docs: callers send `model: fast`, and if the first provider fails before any response is sent, Otari tries the fallback.

```yaml
routing:
  policies:
    fast:
      select:
        - default: openai:gpt-5-mini
      on_failure:
        - anthropic:claude-haiku-4-5
```

5. Run the full stack

   Compose runs Otari on PostgreSQL; the optional profiles add the code sandbox and web search services.

```bash
git clone https://github.com/mozilla-ai/otari
cd otari
cp config.example.yml config.yml
# set a master key, provider credentials and pricing in config.yml
docker compose pull
docker compose up -d
docker compose --profile code-exec --profile web-search up -d
```

## When to use it

- Give teams and applications their own revocable, budget-capped keys without handing out provider credentials
- Fail over from one provider to another, or split traffic between models, behind a single model name
- Track spend, tokens, latency and failures per user, key and model in one place
- Compare two models side by side in the Playground before pointing a routing policy at one

## Version history

- 2026-12-01 v0.60.0: The inference country gate can hold more than one account country, the dashboard sidebar was simplified, and Rules were renamed Guardrails in the web UI.
