Route native and Kenari models inside one Claude Code or Codex CLI session.
Plain claude and codex stay native. Kenari routing only applies when launched
through the wrapper:
kenari claude [args...]
kenari codex [args...]Each launch starts a private router on 127.0.0.1 with a random port, starts the
original CLI with process-scoped overrides, forwards terminal I/O and signals,
then stops the router. No provider setting or credential is written into Claude
Code or Codex configuration.
npm install -g @kenarihq/cli
kenari login
kenari configureNode.js 18 or newer is required.
When Claude Code and Codex are both installed, kenari configure asks which
tool to configure and defaults to Both. If only one is installed, Kenari
selects it automatically. Non-interactive use must name claude or codex.
kenari configure [claude|codex]
kenari reset [claude|codex]
kenari claude [args...]
kenari codex [args...]
kenari status [--check] [--json]
kenari models [--json]
kenari login [--no-browser] [--paste] [--stdin]
kenari logout
kenari help
kenari use and kenari key were removed. Routing is process-scoped and
credentials are managed by login and logout.
Claude Code supports these roles:
mainopussonnethaikufablesubagents
Codex supports these roles:
mainreviewsubagents
Every role can stay native or select a fixed kenari/<model-id>. Codex main
also supports picker. Codex review and subagents also support inherit.
Native is always the default.
For Codex, Kenari detects whether codex login uses ChatGPT or an API key and
keeps native requests on the matching OpenAI upstream. The process-scoped
router disables request compression and WebSocket transport so it can inspect
the model ID before selecting the upstream.
Automation must set every role:
kenari configure claude \
--main native \
--opus native \
--sonnet kenari/glm-5-2 \
--haiku native \
--fable native \
--subagents native \
--yes
kenari configure codex \
--main picker \
--review inherit \
--subagents kenari/gpt-5.4 \
--yesUnprefixed model IDs always route to the native provider. kenari/ model IDs
always route to Kenari. Routing never falls back between providers.
Kenari owns these files:
~/.kenari/config.json
~/.kenari/credentials.json
~/.kenari/model-cache.json
~/.kenari/state.json
The directory uses mode 0700 and files use mode 0600 on POSIX systems.
Writes are atomic. The Kenari credential is stored only in
credentials.json, never in Claude Code settings, Codex configuration,
generated model catalogs, command arguments, or logs.
KENARI_HOME, CLAUDE_CONFIG_DIR, and CODEX_HOME override their matching
directories. KENARI_BASE_URL overrides the Kenari gateway. HTTP gateways are
rejected unless KENARI_ALLOW_HTTP=1 is set for local development.
kenari configure fetches and validates the model catalog. The cache is fresh
for 24 hours.
- Native-only configuration works without login or catalog access.
- A stale valid cache can be used when refresh fails.
- A required Kenari route without a valid cache or credential fails closed.
- A removed or unknown Kenari model fails closed.
kenari statusis offline.kenari status --checkruns bounded network checks.
kenari reset removes routing choices without changing native tool
configuration or login state. kenari logout removes only the Kenari
credential. Native routes keep working after logout.
MIT