Casbin Gateway: a security gateway for the AI coding agents on your machine Apache released Casbin Gateway, a local security gateway that installs with a single command and runs on http://localhost:17000 to govern the AI coding agents on a machine. The tool compiles roughly forty switches over each agent's tools, models and providers into a Casbin policy enforced on every relayed request, supports 44 vendor presets plus any OpenAI- or Anthropic-compatible base URL, and tracks requests, tokens, cache hit rate and cost by model. It manages agents including Claude Code, Codex CLI, Gemini CLI, Cursor, Windsurf, Cline and Qwen Code, storing data in a local SQLite file with default credentials admin/123 that only matter if the gateway is exposed to the network. English | 中文 https://github.com/apache/casbin-gateway/blob/master/README zh.md Every coding agent on the machine Any model vendor behind one endpoint One command. No database, no Go, no Node, no configuration. On Linux and macOS: curl -fsSL https://raw.githubusercontent.com/apache/casbin-gateway/master/scripts/install.sh | bash On Windows, in PowerShell: irm https://raw.githubusercontent.com/apache/casbin-gateway/master/scripts/install.ps1 | iex Either one downloads the build for this machine, unpacks it into ~/.local/share/casbin-gateway %LOCALAPPDATA%\casbin-gateway on Windows , puts a casbin-gateway command on your PATH, starts it, and arranges for it to start again when you log in. The terminal you installed from is yours again straight away. Gateway then opens in its own window — no sign-in: it serves this machine only and signs the local admin in on sight. Closing that window leaves Gateway running behind its tray icon, which is also where you reopen the window, turn Start at Login off and on — Settings → Startup is the same switch — and quit for real. There is a Casbin Gateway entry on your desktop and in the Start menu, in ~/Applications , or in the application menu, depending on the platform. An archive unpacked by hand gets the same entry the first time the launcher runs. If you would rather use a browser, or you are on a machine with no desktop at all, everything is still at http://localhost:17000 http://localhost:17000 , and casbin-gateway start runs the server on its own with no window and no tray. That is the whole installation. Gateway keeps its data in a SQLite file inside its own directory. The password behind that account is admin / 123 , and it only matters if you open Gateway to the network — see Serving other machines serving-other-machines . | Every agent on this machine | Everything those agents carry | |---|---| | What each one runs on, which account it is signed in to, what it has spent there, and whether it is running | Every skill, MCP server and instruction file of every agent, side by side, copied from one agent to another | | What each agent is allowed to do | Which build each agent is on | |---|---| | Around forty switches over the agent's tools, models and providers, compiled to a Casbin policy and enforced on every request it relays | The build on this machine against the one its package manager publishes, installed, upgraded, rolled back or removed from the row it is on, whichever way it was installed | | What the agents spent | One endpoint per model vendor | |---|---| | Read from the transcripts the agents write themselves, so it counts what never went through Gateway too | 44 vendor presets, or any OpenAI- or Anthropic-compatible base URL | | Everything the agents relayed | The whole request, not just a count | |---|---| | Requests, tokens, cache hit rate and cost, broken down by model | The system prompt, every message, and the schema of every tool the model was offered | | Agent | Monitoring | Provider | MCP | Skills | Prompt | Sessions | Install | |---|---|---|---|---|---|---|---| | Claude Code | ✅ | ✅ Anthropic | ✅ | ✅ | ✅ | ✅ | npm · brew · winget · script | | Claude Desktop | ✅ | — | ✅ | — | — | ✅ | winget | | Codex CLI | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | npm · brew · winget · self | | ChatGPT Desktop Codex | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | store | | Gemini CLI | ✅ | ✅ Gemini | ✅ | ✅ | ✅ | ✅ | npm | | Cursor | ✅ | — | ✅ | ✅ | — | ✅ | brew · winget | | Cursor Agent | ✅ | — | ✅ | ✅ | — | — | script · self | | Windsurf | ✅ | — | ✅ | — | ✅ | — | brew · winget | | Cline | — | ✅ OpenAI | ✅ | ✅ | — | — | npm | | Qwen Code | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | npm | | iFlow CLI | — | ✅ OpenAI | ✅ | — | ✅ | — | npm | | Kimi Code CLI | — | ✅ OpenAI | ✅ | ✅ | ✅ | — | npm · winget | | CodeBuddy Code | — | ✅ OpenAI | ✅ | ✅ | ✅ | — | npm | | Roo Code | — | — | — | — | — | — | — | | Copilot CLI | — | — | — | — | — | — | npm | | Continue | — | ✅ OpenAI | — | — | — | — | npm | | Zed | — | ✅ OpenAI | — | — | — | — | brew · winget | | Aider | — | ✅ OpenAI | — | — | — | — | — | | goose | — | ✅ OpenAI | — | — | — | — | brew | | Crush | — | — | — | — | — | — | npm · winget | | Droid | — | ✅ OpenAI | — | — | — | — | — | | Trae | — | — | — | — | — | — | brew · winget | | opencode | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | npm · winget · self | | opencode Desktop | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | winget | | OpenAgent | ✅ | — | — | — | — | — | — | | OpenClaw | ✅ | ✅ OpenAI | ✅ | ✅ | ✅ | ✅ | npm | | Hermes Agent | ✅ | ✅ OpenAI | — | — | — | — | self | | DeepSeek Harness | ✅ | ✅ OpenAI | ✅ | ✅ | — | ✅ | npm | | Pi | — | ✅ OpenAI | — | ✅ | ✅ | — | npm | - Monitoring — audit-only records of what the agent did: prompts, tool calls, permission prompts. Nothing an agent does waits on Gateway, and no answer changes because monitoring is on. - Provider — Gateway writes the agent's own configuration to point it at a bound provider, in the wire format that agent's client speaks. An agent without it still reaches Gateway through the environment variables the UI shows. - MCP · Skills · Prompt — read, compare and copy MCP servers, skills and the instruction file between agents. - Sessions — prompts and token usage read straight from the agent's own transcripts, including what never went through Gateway. - Install — what Gateway installs, upgrades and removes it with: a package manager npm, brew, winget, the Microsoft store , the agent's own updater self , or the vendor's own install command script . An app that arrived as a setup program is still removed with the uninstaller it registered. Everything else is a download from its vendor's page. - Is the API behind that key what it was sold as? the-killer-feature-is-the-api-behind-that-key-what-it-was-sold-as — a reseller can quietly swap in a cheaper model or fake a cache hit, and none of it shows up in the traffic. Authenticity asks the upstream directly and grades it A–F. - Switch every agent's provider from one place send-an-agents-traffic-through-gateway — change an API key or base URL once, and every agent pointed at Gateway picks it up. - Add a provider, an MCP server, a prompt or a skill from a link import-from-a-link — click a vendor's "add this" button on the web and Gateway opens with what the link carries, before any of it is written. - Run several instances of one agent side by side what-to-do-next — e.g. multiple Claude Desktop instances, each signed in to a different account. - Install, upgrade and roll back the agents themselves what-to-do-next — which build each agent is on against what its package manager publishes, and back to an older release when an update broke something. One click whichever way it was installed, with the command shown first, its progress on the row and its console output a click away. - See the whole request, not just a count recording-prompts — every prompt, message and tool schema an agent sent, kept on this machine. - Say what each agent may do what-each-agent-is-allowed-to-do — around forty switches per agent, in groups, over its tools, models and providers, enforced by Casbin on every request it relays. - Know what every agent spent, even off Gateway what-the-agents-spend-including-what-never-went-through-gateway — read straight from the agents' own transcripts. - Compare and copy skills, MCP servers and prompts across agents what-to-do-next — every agent's install list in one table. - Connect an application once, for every agent https://github.com/apache/casbin-gateway/blob/master/docs/user-manual/en/2-agents/2.5-connections.md — 45 of them: GitHub, Slack, Lark, DingTalk, Notion, Figma, Sentry, Kubernetes, Stripe, mail, a browser and the rest. The credential stays in Gateway rather than in each agent's config file, every call through it is checked against that agent's permissions, and testing one gives you a switch per tool. The version Gateway is running sits in the top-right corner, with the date it was built, and it says New when the published build is a later one. Open it and press Update now : Gateway downloads the build for this machine, checks that it runs, puts it in place of itself and restarts into it. The page reloads on the new version when it comes back, and nothing else has to be touched — the data, the settings and the casbin-gateway command all stay where they are. Gateway installed some other way, or in a directory it cannot write to, says so and shows the install command to run by hand instead. | Page | What you get | What it needs | |---|---|---| | Agents | Every AI coding agent installed on this machine — Claude Code, Codex CLI, Cursor, the Gemini CLI, opencode and more — four cards to a row, each naming the account it is signed in to, the provider it answers to, what it has spent — day by day over the last month, wherever its own transcripts carry that much — and whether it is running right now. Start or stop one from its card, or run several instances of the same agent at once, each with a state directory and an account of its own. An agent this machine does not have is listed too, and installed or upgraded from the page through the package manager the host already has. Gateway reports which installations have a newer release waiting, moves one onto any version its manager still publishes - back to an older one when an update broke something - and uninstalls it, leaving the agent's own sign-in and history where they are. An agent unpacked by hand is found on PATH as well as in the layouts installers write, and one hiding somewhere neither describes is pointed at directly: Locate browses this machine and lists the program you pick as an installation of its own, without moving or changing anything. | Nothing | | Agent versions | Every agent Gateway knows in one table: the build on this machine, the release its package manager publishes, and whether the two differ. Install one, upgrade it, put it back on an older release, or remove it, from the row it is on - in one click, whichever way it was installed: a package manager, the Microsoft Store, the uninstaller the app registered with Windows, the agent's own updater, or the vendor's own install command. The command is shown before it runs, the row carries its progress while it does, and everything it printed is a click away. | Nothing | | Skills, MCP & Prompts | Every skill, MCP server and instruction file of every agent in one table. Install skills from a GitHub repository, a .zip or .tar.gz , or a folder on this machine, into one agent or several at once. Add an MCP server the same way, edit the instructions an agent reads before every session, open one, delete it, or copy it into another agent. | Nothing | | Sessions | Every session those agents have had, read from the transcripts they leave on disk: the whole conversation, message by message. How many there are, how many ran today and how many came from a transcript rather than from monitoring, then filtered down to one agent or one of those two sources. | Nothing | | Activity | What a monitored agent is doing as it does it — each tool call, its target and how long it took. | Monitoring on for an agent | | Providers | One endpoint in front of your model vendors. Gateway holds the API key, so the agents never have it — or forwards the agent's own sign-in and holds nothing. | A vendor API key, or nothing at all | | Authenticity | A score out of 100 and a grade for every provider, measured without being asked — see the section below the-killer-feature-is-the-api-behind-that-key-what-it-was-sold-as . | A provider with an API key | | LLM Records | Every request an agent relayed: the full system prompt, every message and tool call, the schema of every tool the model was offered, plus tokens and cost. | A provider, and llmRecordMode — see Recording prompts recording-prompts | | Usage | What every agent on this machine spent, over time and broken down by model and by agent, read from the agents' own transcripts — so it counts the requests that never went through Gateway. A second tab shows what Gateway relayed, which is the only account that knows which provider answered and whether it failed. | Nothing | | Model pricing | What a million tokens costs, which is what every figure on the Usage page is worked out from. Edit a price by hand, or let Gateway reprice the models this machine has run from the models.dev https://models.dev catalogue on a schedule; a price you edited yourself is left alone. | Nothing | A page with tabs or sections is in the sidebar under its own name, so the rail lands on the test cases, the MCP servers or the security settings rather than only on the top of the page they are on. ⌘K , or Ctrl+K , opens a search box over whichever page you are on: every page by name, and every agent and provider on this machine, which is how you reach one of thirty providers without paging through the list. The header switches the UI between light and dark, between three palettes — Amber & Ink , Terminal and Indigo — and between English and Chinese. Agents are found by reading the user accounts, home directories and install paths of the machine Gateway runs on , so run it on the machine whose agents you want to watch. A reseller can sell a frontier model and serve a cheaper one, count a cached prefix as fresh input, or answer in an API it only pretends to speak. None of that shows up in the traffic, so Authenticity asks the upstream directly. Every provider is probed on its own — when it is added, when its endpoint, type or key changes, when it has never been probed, and again whenever its report goes stale — and comes back with a score out of 100 and a grade from A to F, on the Authenticity page and above the agents on the home page. No button to press, and nothing to configure. The score is only a summary of the test cases behind it, and every one of them is on the page. Half of them ask what the upstream is: whether the model that answers is the one that was asked for — worth half credit off a vendor's own endpoint, where that field is whatever the upstream typed there — which vendor the model says trained it, whether anything was injected in front of the request, whether several identical requests come back from the same model at all, and whether a parameter the API documents logprobs , n , a stop sequence is honoured, refused, or accepted with a 200 and quietly dropped. A test bank asks questions with one right answer, from counting the letters in a word to who wrote the Preface to the Pavilion of Prince Teng. The rest read the envelope: whether a two-level tool schema survives a forced call, whether the event stream carries everything the API documents, whether the prompt cache is really accounted for, whether two identical requests are billed the same, whether the vendor's own headers are there. Each case names the question it puts to the upstream, the exact request it sends, how the answer is judged, and what it is worth. Reweight a case, turn it off, rewrite its question, or add one of your own — the questions worth asking of a reseller are not the same everywhere, and a score whose method is not published is not evidence. Restore defaults puts the shipped suite back and leaves your own cases alone. The report has a second half that costs nothing and sends no request: what the records Gateway already kept say about that upstream — how much of the cache it really accounted for, how many attempts failed, how long it took to answer, and how much of what it served has no price. A probe spends a few cents of that provider's own credit, which is on the report next to the finding. providerProbeIntervalHours sets how often a report goes stale, providerProbeMode = "manual" probes only when asked, and "off" never probes. This is what fills LLM Records , and what lets Gateway keep the vendor key instead of the agent. 1. Providers → Add : pick the type OpenAI- or Anthropic-compatible , paste the vendor base URL and API key, and list the models it serves. 2. Agents → open an agent → pick that provider. For an agent whose configuration format Gateway knows, Write configuration puts it in the agent's own file — Preview shows exactly what that will be first, and Restore undoes it. Picking a different provider afterwards rewrites the file on the spot, so switching from then on is one click, from either page. 3. For any other agent, copy the environment snippet the page shows and start the agent from a shell that has it: export ANTHROPIC BASE URL="http://localhost:17000/v1/agents/claude-code" export ANTHROPIC AUTH TOKEN="cg-..." The token is Gateway's own relay token, not a vendor key: the agent refuses to start without something in that variable, and Gateway authenticates upstream with the provider's key instead. The snippet on the page already has the real value filled in. One base URL answers whichever API the agent speaks: /chat/completions for an OpenAI client, /v1/messages for an Anthropic one, /responses for Codex, which speaks nothing else since it dropped the chat completions wire format, and /v1beta/models/