Skip to content

feat(login): choose otari.ai region or own gateway at /login otari - #83

Merged
tbille merged 1 commit into
mainfrom
feat/login-region-and-gateway
Nov 18, 2026
Merged

tbille merged 1 commit into
mainfrom
feat/login-region-and-gateway

Conversation

@tbille

@tbille tbille commented Nov 18, 2026

Copy link
Copy Markdown
Member

Summary

/login otari in Pi only asked for an API key, so there was no way to pick otari.ai's EU region or point at a local/self-hosted gateway without setting OTARI_BASE_URL.

The login now:

  1. Asks which Otari: otari.ai, otari.ai EU region (https://eu.api.otari.ai/api/v1), or Your own gateway… (URL prompt; /api/v1 added when left out; HTTP only for loopback).
  2. Asks for the API key with the same masked prompt as before.
  3. Checks the key against {url}/models before saving, so a bad key or unreachable gateway fails at login. A 421 from otari.ai naming the key's region switches to that region automatically. Only otari.ai region hosts are followed, so the key is never sent elsewhere.
  4. Stores the gateway URL with the key (env.OTARI_BASE_URL on the API-key credential).

Requests (through auth.baseUrl), model discovery, subagent routing and gateway tools all follow the stored gateway.

Which settings win: a saved login (key + gateway) wins over OTARI_API_KEY / OTARI_BASE_URL. After /logout otari those two apply again. Keys saved by older versions have no gateway recorded and keep using OTARI_BASE_URL.

Changes

  • src/login.ts (new): the login flow and how the saved key and gateway are read back.
  • src/config.ts: the list of otari.ai regions; URL checks reusable by the login, and they accept the EU host.
  • src/provider.ts: uses the new login; discovery and refresh follow the stored gateway.
  • README: documents the login choices and which settings win.

Not covered

omp (omp login otari) still only asks for a key. Its login API can't store a URL next to a plain key, so it needs a different approach in a follow-up.

Testing

  • npm test: all 254 pass. New unit tests cover region choice, a custom gateway URL, an HTTP URL that isn't localhost, following the 421 to the right region, refusing a 421 that points outside otari.ai, a rejected key, an unreachable gateway, an empty key, how the saved key and URL are read back, and discovery against the stored gateway.
  • The integration test now logs in to a local gateway with no OTARI_BASE_URL set and checks that a restarted session still uses the saved URL.
  • tsc --noEmit and biome are clean.
  • Not tried by hand in an interactive Pi session yet.

🤖 Generated with Claude Code

/login otari now asks which Otari to use (otari.ai, otari.ai EU region,
or a self-hosted/local gateway URL) before the API key, verifies the key
against {url}/models, follows otari.ai's 421 to the region that minted
the key, and stores the gateway URL with the credential. Requests,
discovery, routing and gateway tools follow the stored gateway; a stored
login wins over OTARI_API_KEY/OTARI_BASE_URL, which remain the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1d82a4cd-96b2-456e-bf95-b10f1c90677e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@tbille
tbille merged commit 609062a into main Nov 18, 2026
2 checks passed
@tbille
tbille deleted the feat/login-region-and-gateway branch November 18, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant