> ## Documentation Index
> Fetch the complete documentation index at: https://onr.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Open Next Router

> Nginx-like, atomic DSL routing for modern AI providers.

## A DSL-driven LLM gateway

Open Next Router (ONR) routes requests, applies opt-in compatibility transforms, and normalizes streaming behavior across providers, without hiding logic in code.

<div className="flex flex-wrap gap-3 mt-6">
  <Button href="/getting-started/quickstart">Get started</Button>
  <Button href="/dsl/overview" variant="secondary">Read the DSL model</Button>
</div>

<Callout type="info" title="Design principle">
  Runtime behavior must be described explicitly by DSL directives loaded from `config/onr.conf`, which typically includes files under `config/providers/*.conf` (see [config/onr.conf](https://github.com/r9s-ai/open-next-router/tree/main/config/onr.conf)). The runtime proxy stays an execution engine, not a guessing layer.
</Callout>

## Architecture at a Glance

```mermaid theme={null}
flowchart TD
    %% Base styling
    classDef default fill:#1a1b26,stroke:#414868,stroke-width:1px,color:#c0caf5;
    classDef layer fill:#1f2335,stroke:#292e42,stroke-width:1px,color:#a9b1d6,rx:10,ry:10;
    classDef file fill:#24283b,stroke:#565f89,stroke-width:1px,color:#7aa2f7,rx:4,ry:4;
    
    subgraph ClientLayer ["Client Layer"]
        direction TB
        Clients["API Clients<br/>(OpenAI-compatible request)"]
    end

    subgraph RuntimeApp ["HTTP Server Pipeline"]
        direction TB
        Server["Gin HTTP Server Setup"]
        
        subgraph Middlewares ["Middleware Chain"]
            direction TB
            ReqID["Request ID Injection"]
            Auth["Bearer & TokenAuth"]
            Dump["Traffic Dump Auditing"]
            ReqID --> Auth --> Dump
        end
        
        subgraph Proxy ["Proxy Runtime"]
            direction TB
            Router["Model Request Router"]
            Exec["DSL Executor Engine"]
            Router --> Exec
        end
        
        Server --> ReqID
        Dump --> Router
    end

    subgraph Configs ["Configuration Files"]
        direction LR
        DSLConf("onr.conf + included .conf files<br/>(Routing Rules)")
        OnrYaml("onr.yaml<br/>(Gateway Config)")
        KeysYaml("keys.yaml<br/>(Access Control)")
        ModelsYaml("models.yaml<br/>(Model DNS)")
    end

    subgraph CoreLib ["DSL Processing Core"]
        direction TB
        Registry["In-Memory Registry"]
        Transform["JSON Transformers"]
        SSEParse["SSE Stream Parsers"]
        
        Registry --> Transform
        Registry --> SSEParse
    end

    subgraph Upstream ["Upstream Provider APIs"]
        Providers["OpenAI, Anthropic, Gemini, etc."]
    end

    %% Main flow
    Clients --> Server
    Exec <--> Providers
    Exec --> Registry
    
    %% Config Loading
    Server -. "Bind" .-> OnrYaml
    Auth -. "Check" .-> KeysYaml
    Router -. "Match" .-> ModelsYaml
    Registry -. "Parse" .-> DSLConf

    class ClientLayer,RuntimeApp,CoreLib,Configs,Upstream,Middlewares,Proxy layer;
    class DSLConf,OnrYaml,KeysYaml,ModelsYaml file;
```

## Jump in

<Cards>
  <Card title="Quickstart" href="/getting-started/quickstart">
    Run locally, validate configs, and hit `/v1/models`.
  </Card>

  <Card title="Configuration" href="/configuration/onr-yaml">
    `onr.yaml`, `keys.yaml`, `models.yaml`, reload and env overrides.
  </Card>

  <Card title="DSL" href="/dsl/overview">
    `defaults` + `match`, phases, directives, and streaming transforms.
  </Card>

  <Card title="API" href="/api/overview">
    OpenAI-compatible endpoints plus Gemini v1beta subset.
  </Card>
</Cards>

## 30-second Quickstart

```bash theme={null}
make build
onr run -c onr.yaml
curl -sS http://127.0.0.1:3300/v1/models -H "Authorization: Bearer change-me"
```

## What you get

* **Atomic DSL**: declare routing/auth/transforms/SSE parsing in config, not code.
* **Safe defaults**: first match wins; no-match returns HTTP 400 (no silent fallback).
* **Streaming-aware**: normalize SSE framing and provider chunk semantics.
* **Ops-friendly**: one-line access logs, optional traffic dumps, optional usage/cost extraction.

## Where to Start

* Start with [Quickstart](/getting-started/quickstart).
* Skim [Why ONR](/concepts/why-onr) and [Architecture](/concepts/architecture).
* Read [DSL Overview](/dsl/overview), then author provider files with [Provider Config](/reference/provider-config).
