Apache Casbin Gateway
1. Getting started

1.1 Introduction

Casbin Gateway is a local gateway for the AI coding agents installed on your machine. It finds them, shows what they carry, puts one endpoint in front of the model vendors they talk to, and keeps the record of what they did and what it cost.

It runs on the machine whose agents you want to watch. Nothing is sent anywhere: the database is a file next to the executable, and the UI binds to 127.0.0.1 unless you say otherwise.

What it is for

You want toGateway does it on
Know which agents are on this machine, which account each is signed in to and what it spentAgents, Usage
Install, upgrade or roll back the agents themselvesAgent versions
Change an API key once instead of in eight configuration filesProviders, Routing
Run Codex on DeepSeek, or Claude Code on QwenRouting
Find out whether a reseller really serves the model it sellsAuthenticity
Take the terminal, or one MCP server, away from one agentPermissions
Read the whole request an agent sent, prompt and tool schemas includedLLM Records
Keep an API key out of the agent that uses itRouting, Connections

How it fits together

   agents on this machine           Casbin Gateway               model vendors
+------------------------+     +----------------------+     +------------------+
| Claude Code            |     | permissions (Casbin) |     | OpenAI           |
| Codex CLI              |---->| translation          |---->| Anthropic        |
| Gemini CLI, Cursor ... |     | records + usage      |     | DeepSeek, Kimi   |
+------------------------+     | provider keys        |     +------------------+
            ^                  +----------------------+
            |  reads their config, transcripts, skills and MCP servers
            +----------------- same machine -----------------

Two independent halves, and either is useful without the other:

  • The proxy. An agent pointed at Gateway has its requests authenticated, checked against its permissions, translated into whatever API the provider speaks, relayed, and recorded. Gateway holds the vendor key, so the agent never has it.
  • The reader. Agents are discovered by reading the home directories, install paths and transcripts of this machine. That works from the first start, with no provider configured and nothing routed — which is why Usage can account for requests that never went through Gateway at all.

Because the reader half works on files this machine owns, Gateway has to run on that machine. In a container it sees the container's own filesystem and finds nothing — see 5.4 Docker and Podman.

What each agent gets

Around thirty agents are recognised, and how far Gateway goes with each one differs. The table in the README is the current list, column by column:

  • Monitoring — audit-only records of prompts, tool calls and 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 file to point it at a bound provider, in the format that agent's client speaks. An agent without this still reaches Gateway through environment variables.
  • MCP · Skills · Prompt — read, compare and copy MCP servers, skills and instruction files between agents.
  • Sessions — conversations and token usage read from the agent's own transcripts.
  • Install — how Gateway installs, upgrades and removes it: npm, brew, winget, the Microsoft Store, the agent's own updater, or the vendor's own install script.

Built with

PartStack
BackendGo, Beego, XORM, Casbin
FrontendTypeScript, React, shadcn/ui
StorageSQLite by default; any database XORM supports
LicenceApache-2.0

Next: 1.2 Installation.

Edit on GitHub
Apache Incubator

Apache Casbin (Incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Copyright © 2026 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.

Apache, Apache Casbin, the names of Apache projects, and the feather logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. All other marks mentioned may be trademarks or registered trademarks of their respective owners.

On this page