@larridin-ai/router
v0.9.0
Published
One-command installer that connects AI coding tools to the Larridin Router.
Readme
@larridin-ai/router
Connects your AI coding tools to your company's Larridin Router, so requests are routed, metered and governed by your company's model policy.
It sets up Claude Code (the terminal CLI and the VS Code / Cursor extension), Codex and opencode.
Setup
Ask a Larridin admin for your router key (it starts with larridin_router_), then run:
npx @larridin-ai/router connect --key <your key>That lists the tools it finds and whether each is connected, then asks what to do, with Connect
first: connect the tools that are not connected yet, or put this key on the ones that are. The
key answers only the key question; add -y to connect every tool it finds with it, asking
nothing:
npx @larridin-ai/router connect --key <your key> -yThe key stays in your shell history; to keep it out, use the hidden prompt instead:
npx @larridin-ai/router connect --new-keyPlain npx @larridin-ai/router walks you through the same steps. A key already on this machine
is offered first, masked and named by the tool it came from, so you choose between it and a new
one. Flags answer their own question and leave the rest alone.
It never prompts when there is no terminal to prompt on -- a pipe, a script, CI set --
and -y or --no-input makes it silent on a terminal too. For scripts, read the key from
LARRIDIN_ROUTER_KEY, filled from a secret store:
export LARRIDIN_ROUTER_KEY="..." # from your secret store
npx @larridin-ai/router connect -y
npx @larridin-ai/router connect -y --tools codexGive the key one way: --key together with --new-key or with LARRIDIN_ROUTER_KEY is refused.
Then quit and reopen Claude Code. Sessions that are already open keep their old settings.
Check and undo
npx @larridin-ai/router status
npx @larridin-ai/router update
npx @larridin-ai/router disconnectupdate refreshes the router files of every connected tool to this version and keeps your key.
disconnect lists the connected tools and asks before removing what connect added. With
more than one connected, it first asks whether to disconnect all of them or one. It does not
need your key. Without a terminal it removes nothing unless you pass --yes, so a script runs
npx @larridin-ai/router disconnect --yes, with --tools to narrow it; --dry-run only
lists.
One exception, for Codex: the [model_providers.larridin_router] entry is left in
config.toml, because Codex refuses to open a session whose provider is missing
from the config. The entry is kept without your router key: disconnect takes the key out of
it, and an entry nothing points at changes nothing.
Codex and your existing sessions
Codex lists sessions for the provider that is currently active. After connecting,
/resume shows sessions created through the router, and ones from before are
hidden. Nothing is deleted, and disconnecting makes them visible again. After
disconnecting, sessions created through the router are hidden instead, until you
connect again. connect and disconnect both say this before they change anything.
A session resumed by id keeps the provider it was created with, so an older one continues on OpenAI rather than through the router. Sessions started after connecting use the router.
Copilot CLI
connect routes GitHub Copilot CLI through its own files, with no environment variables:
~/.copilot/providers.json(or$COPILOT_PROVIDERS_CONFIG) gains alarridinprovider, which holds your router key, and your organization's Larridin models. Your own providers and models stay. The file is written owner-only (600), like every file that holds the key, and the key is never copied into a backup.~/.copilot/settings.jsongetsmodel: larridin/<default>and the router statusline (run withbash, as Claude Code's is). The statusline refreshes every 30 seconds, since otherwise Copilot redraws it only on events; arefreshIntervalyou set on it is kept. If you had already chosen a default model, it is kept, and Copilot keeps using it, not the router, until you pick a "via Larridin" model in/modelor pass--model larridin/<id>.connectandstatusboth say so. ACOPILOT_MODELthat names another provider overrides the file in the same way.- Copilot is found by its own files (the
config.jsonit writes on its first launch,providers.json,settings.json), not by thecopilotcommand being installed.
Things to know:
/modelforceworks in Copilot too:connectadds its hook to~/.copilot/settings.jsonand amodelforceskill (Copilot lets a typed/modelforcethrough only when one exists). A skill of your own by that name is left alone, and then/modelforcereaches it, not the router.- GitHub. With no GitHub login, Copilot makes no GitHub connection under this setup
(measured). Logged in to GitHub, it can still reach GitHub;
COPILOT_OFFLINE=truestops that, along with GitHub MCP, code search and/delegate.connectdoes not set it. - Your organization's policy. A managed
forceLoginOrgssetting refuses bring-your-own-key, so Copilot will not use the router.connectandstatusreport it when it is in Copilot's managed-settings file (/Library/Application Support/GitHubCopilot/managed-settings.jsonon macOS,/etc/github-copilot/managed-settings.jsonon Linux). Set by an MDM profile or the Windows registry, it cannot be seen from here. - Disconnect removes the
larridinprovider and its models, the router'smodeland statusline, and nothing of yours. Copilot sessions started through Larridin cannot be resumed afterwards. - The Copilot version. Requests tell the router your Copilot version as it was at the last
connectorupdate(fromcopilot --version, else the installed package). Copilot updates itself, and until you runupdateafter that, the router sees the older version.statusshows the version sent. - Running sessions. Copilot reads
providers.jsonwhen a session starts. Afterconnectorupdatereplaces your router key or gateway, sessions already running keep the old ones until you restart them (the statusline and/modelforcefollow the new file at once). - A revoked key.
statusasks your Larridin deployment whether the installed key still works, and reports a rejected one as not connected. - A moved Copilot home. With
COPILOT_HOMEorCOPILOT_PROVIDERS_CONFIGset atconnect, runstatus,updateanddisconnectwith the same variable set; the Undo lineconnectprints carries it. WithoutCOPILOT_PROVIDERS_CONFIG,statusanddisconnectsay when the router's settings remain with noproviders.jsonbeside them. WithoutCOPILOT_HOME, nothing of the moved home can be seen, sodisconnectfinds nothing to remove there. - Hooks in a repository. Copilot also runs a repository's
.claude/settings.jsonhooks: in its interactive mode, and with-ponly in a folder you have trusted (or withCOPILOT_ALLOW_ALLorGITHUB_COPILOT_PROMPT_MODE_REPO_HOOKSset). If you connected Claude Code there with--scope projector--scope local, its/modelforcehook runs under Copilot in that repository too; an ordinary prompt passes through it untouched.connectwrites nothing for Copilot inside a repository.
Notes
- Nothing is written if your key is rejected or the router cannot be reached.
- Your settings file is backed up, with a timestamp, before the first change.
- The statusline shows the model you selected, the model the router served when it differs, this session's tokens and Claude Code's own cost estimate, and whether the session is pinned. It reads Claude Code's own transcript for that; nothing is sent anywhere.
- A setting that already belongs to something else, such as another proxy, is left alone and reported.
- Environment variables can stand in for the common flags, for example
LARRIDIN_ROUTER_KEY. - Needs Node.js 20 or newer.
Run npx @larridin-ai/router --help for the rest: where to write the settings (user, project or local), dry runs, and the optional plugin that adds a /modelforce command. For Codex, connect installs a $modelforce hook instead: $modelforce lists the models, $modelforce 2 pins one for the session, $modelforce auto clears it.
