cd /news/ai-tools/use-the-otari-gateway-with-opencode · home topics ai-tools article
[ARTICLE · art-25100] src=blog.mozilla.ai ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

Use the Otari Gateway with OpenCode

Mozilla.ai has released a new integration allowing developers to route OpenCode AI coding sessions through the Otari Gateway for real-time cost tracking, token usage monitoring, and budget enforcement. The setup requires no changes to application code, as Otari sits between OpenCode and the model provider to log metadata including token counts, model names, and timestamps. Developers can configure the gateway in three steps—creating an Otari account, pointing OpenCode at the gateway, and starting a coding session—to gain visibility and control over AI usage across all models.

read3 min publishedJun 8, 2026

Technical Content

AI coding sessions can feel like a black box. Route OpenCode through the Otari Gateway to track costs, token usage, and model activity in real time. Get budget controls and visibility across every session without changing a single line of application code.

AI coding sessions can feel like operating in a black box. You fire up OpenCode, pick a model, and start working. By the end of the session however, you have no idea what it actually cost you, which requests failed, or how your usage breaks down across models. Even when you're running a capable open-source model like Kimi K2.6 with a 256K context window, inference for those sessions gets expensive fast.

Routing OpenCode through

solves that. Every request you make to OpenCode flows through Otari, so you get per-session cost tracking, budget enforcement, and usage visibility. No changes to application code required.

__Otari__Otari sits between OpenCode and the model provider, resolves credentials server-side, and logs metadata: token counts, model names, timestamps. Your prompts and completions stay yours.

Here's how to set it up in three steps.

1. Set up your Otari account and create a key #

Sign up (or log in) at otari.ai.

Generate an API token

  • Open an existing workspace (or create a new one).
  • Navigate to the API Keys tab. - Click Generate and copy the tk_... key.

Note: This is a one-time reveal, so store your key securely.

Your key talks to the gateway at https://api.otari.ai/v1

, the OpenAI-compatible endpoint that any standard client can point to.

Optional: Add your provider key

Go to Settings → Keys → Provider Keys . Under Your Keys (BYOK), click Add and paste your upstream API key (OpenAI, Anthropic, or whichever provider you're using). Otari stores this and uses it to call the provider on your behalf. Your application never touches it directly.

2. Point OpenCode at Otari #

Add Otari as a provider in your . Set

opencode.jsonc

baseURL

to the gateway and apiKey

to the tk_...

key you just created:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "otari": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Otari Gateway",
      "options": {
        "baseURL": "https://api.otari.ai/v1",
        "apiKey": "tk_YOUR_OTARI_KEY..." 
      },
      "models": {
        "mzai:moonshotai/Kimi-K2.6": {
          "name": "Kimi K2.6 (via Otari)",
          "limit": { "context": 256000, "output": 32000 }
        }
      }
    }
  }
}

Tip: To avoid committing secrets to version control, it is highly recommended to pass your actual API key via an environment variable rather than hardcoding it into the JSON file.

In the above example, we are using Kimi K2.6, a model hosted by Mozilla.ai's managed mzai provider. Kimi K2.6 is an open-source, agentic model with tool calling and a 256K context window.

3. Start Coding #

Pick the Otari model in OpenCode and start working:

opencode --model otari/mzai:moonshotai/Kimi-K2.6

That's it. Every request now flows through the gateway, so you get usage and strict budget tracking across all your models, without changing a single line of your application code.

To verify everything is working, run a quick prompt and check your Otari dashboard.You should see usage stats appearing immediately.

── more in #ai-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/use-the-otari-gatewa…] indexed:0 read:3min 2026-06-08 ·