Skip to content

Repository files navigation

Mada Router

简体中文

Mada Router is a local model router for macOS. It lets Codex, Claude, and other compatible clients use multiple model providers without giving up their native request format. For Codex, it supports official account login alongside third-party providers, so you can switch between them without restarting the client or editing configuration files.

It runs on loopback, keeps provider credentials on your Mac, and gives you one place to see what was routed, how many tokens were used, and where a request failed.

Mada Router overview

What it does

  • Routes Codex and Claude requests through provider-qualified model names.
  • Keeps Codex's official account route available alongside custom providers.
  • Bridges OpenAI Responses and Anthropic Messages in both directions.
  • Preserves streaming responses, tool calls, reasoning, usage, and supported compaction flows across the bridge.
  • Publishes custom models into the Codex model picker.
  • Supports per-agent provider access, Claude model aliases, and local token-count estimates.
  • Tracks request activity in memory and token usage in a local SQLite database.
  • Captures redacted diagnostics only when Diagnose is enabled for that agent.

Routing

Mada Router listens on 127.0.0.1:18766 by default. Each client gets a named local entry point:

http://127.0.0.1:18766/codex/v1
http://127.0.0.1:18766/claude

A provider-qualified model goes to that provider. An unqualified Codex model stays on the official Codex route.

mada/gpt-5.6-sol   ->  provider "mada", model "gpt-5.6-sol"
gpt-5.4            ->  Codex official backend

Provider names are part of the public model ID. The rest of the ID is passed upstream unchanged, so IDs such as mada/anthropic/claude-sonnet-4 work as expected.

Mada Router removes client credentials before a request is sent to a custom provider and adds only that provider's configured token. Redirects are not followed, which keeps provider credentials bound to the configured origin.

Agent support

Codex

Mada Router can manage the Codex base URL and supplemental model catalog. Close Codex before starting it from Mada Router; the app prepares the local configuration, launches Codex, and restores managed settings when the integration is stopped.

Unqualified model IDs continue to use the official Codex backend. Custom providers use the provider/model form.

Claude

Claude uses the Anthropic Messages entry point. Copy the Claude base URL shown in Mada Router into Claude's Gateway configuration, then assign provider access and any aliases in Mada Router.

Mada Router does not edit Claude's configuration or force-quit Claude Desktop.

Other clients

Clients that speak OpenAI Responses can use a path such as /<client-name>/v1. These generic entries are provider-only: requests must use a configured provider/model ID and do not fall back to an official backend.

Providers

Providers use one of two wire protocols:

  • OpenAI Responses
  • Anthropic Messages

You can add providers and models from the Providers page. Models may also override catalog metadata such as context window, supported reasoning levels, image input, and web search support.

Provider configuration

Activity and usage

Activity shows the most recent requests for the current app session. It is useful for checking the selected route, HTTP outcome, token totals, and active streams without opening a terminal.

Recent request activity

Usage is stored locally and can be viewed by time range, agent, provider, and model. Input, output, cache-read, and cache-write tokens are tracked separately when the upstream reports them.

Token usage

Local data and privacy

Mada Router stores its runtime data under:

~/Library/Application Support/Mada Router/

The main files are:

config.toml                 provider and routing configuration
state/usage.sqlite3         token usage and request outcomes

Provider tokens are stored in the owner-only local config. They are redacted from Activity records, exports, and debug output.

Activity history is memory-only. The app keeps the latest 50 model requests and 50 auxiliary requests per agent for the current session. Usage event detail is retained for 31 days; lifetime aggregate totals are kept separately.

Diagnose is off by default and controlled per agent. When enabled, Mada Router captures bounded, redacted request and response artifacts. Nothing is written to disk unless you explicitly export Activity data. Exports are placed under:

~/Downloads/madarouter-request-log/<agent>/

Treat exported diagnostics as sensitive even though known credentials and account identifiers are redacted.

Build from source

Mada Router currently targets macOS.

You will need:

  • Node.js and pnpm
  • Rust stable
  • Xcode Command Line Tools

Start the development build:

pnpm install
pnpm tauri dev

Run the checks:

pnpm check
cargo test --workspace

Build a DMG:

pnpm tauri build

The bundle is written to:

target/release/bundle/dmg/*.dmg

On machines where Finder's DMG layout AppleScript fails, skip that cosmetic step with:

CI=true pnpm tauri build

Project layout

src/                    Svelte desktop UI
src-tauri/              Tauri app, tray, lifecycle, and agent integrations
crates/router-core/     configuration, mutations, registry, and routing policy
crates/router-runtime/  HTTP/SSE relay, protocol bridges, activity, and usage
docs/adr/               architecture decisions

The domain crate deliberately has no Tauri, network, filesystem, credential, or port dependencies. Runtime routing uses immutable configuration snapshots, so an in-flight request keeps the route it started with while later requests see configuration changes.

Status

Mada Router is under active development. Configuration formats and integration behavior may still change before a stable release. If you are testing a new provider, keep its official client available until you have verified streaming, tools, and long conversations through the router.

Bug reports should include the macOS version, client version, provider protocol, request outcome, and a redacted Activity export when possible. Never post provider tokens, account identifiers, or unredacted request content in a public issue.

About

A local model router for Codex, Claude, and compatible clients on macOS.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages