Docs

Architecture

How requests flow through the gateway.

OpenThena is intentionally small. The request path is:

text
Browser (/chat)
   │  POST /api/chat  { messages, model }
   ▼
Edge route (stateless, no logging)
   │  getModel(id) → LiteLLM-style gateway
   ▼
Provider (Xiaomi MiMo  ·  OpenAI-compatible)
   │  streamed tokens
   ▼
Browser  ◀── token stream ──  (history saved to localStorage)

The gateway

src/lib/ai/gateway.ts is the heart of the system. It holds a registry mapping friendly model ids to a provider and an upstream model name. getModel(id) returns a configured AI-SDK model. If LITELLM_BASE_URL is set, every request is routed through that proxy instead of the provider directly.

typescript
const MODEL_REGISTRY = {
  "mimo-v2.5-pro": { provider: "mimo", model: "mimo-v2.5-pro" },
  "mimo-v2-pro":   { provider: "mimo", model: "mimo-v2-pro" },
  "mimo-v2-flash": { provider: "mimo", model: "mimo-v2-flash" },
};

The edge route

src/app/api/chat/route.ts runs on the edge. It validates the payload, calls streamText(), and returns a streamed response with Cache-Control: no-store. It writes nothing to any store.

The server is a pure relay. There is no place in the code that persists a message.