Apache Casbin Gateway
1. 开始使用

1.4 快速上手

五分钟,从装好到能读一个Agent的流量。

第0步——你已经有的

打开Agent客户端。本机装的每个Agent都在那儿,带着它登录的账号、它使用的供应商、以及它花了多少——只要它自己的会话记录能追溯到,就按天铺开最近一个月。

用量页同样已经有数据了,来源是同一批会话记录。这两页都不需要供应商、不需要Key、不需要接任何流量。如果你只是想知道本机这些Agent到底在烧多少钱,到这里就结束了。

第1步——加一个供应商

供应商→新增:

  1. 选类型:OpenAI或Anthropic,看厂商文档写的是哪套API。
  2. 粘贴厂商的基础URL和API Key。
  3. 填上它提供的模型。

存之前Gateway会先探一次上游,从此真伪检测会自动给它打分。

手上只有ChatGPT或Claude订阅、根本没有API Key?在来源里选那个订阅,登录一次就行,见3.3。

第2步——把Agent指过去

Agent客户端→打开一个Agent→选中那个供应商。

  • 对于Gateway认得其配置格式的Agent,写入配置会直接改它自己的配置文件。预览先把要写的内容原样给你看,恢复可以撤销。
  • 其他Agent,复制页面上的环境变量片段,在带着这些变量的shell里启动它:
export ANTHROPIC_BASE_URL="http://localhost:17000/v1/agents/claude-code"
export ANTHROPIC_AUTH_TOKEN="cg-..."

这个token是Gateway自己的中继令牌,不是厂商的Key。Agent那个变量为空就不肯启动,而Gateway对上游用的是供应商的Key。

之后再换一个供应商,配置文件当场重写,所以从此切换只需要一次点击。

第3步——跑一次,然后读它发了什么

正常用这个Agent,然后打开LLM记录:它转发的每个请求都在里面——完整的system提示词、每一条消息和工具调用、模型看到的每个工具的schema,外加token和费用。

如果这不是你想留下的东西,在接入Agent之前就改:页面顶部的选择器有关闭记录、只记录元数据、记录元数据和正文三档(4.2)。

第4步——决定这个Agent能做什么

权限→选中该Agent。四十来个工具开关,分六组,外加它可以用哪些模型、哪些供应商。关掉的工具会在请求离开这台机器之前被摘掉,模型压根看不到它(4.1)。

接下来看什么

你想看
判断那个Key背后的中转商老不老实3.4 真伪检测
让Codex用上它本来不支持的模型3.2 让Agent的流量走Gateway
安装或回滚Agent本身2.2 版本管理
把GitHub、Notion或某个目录给Agent用,又不想把token粘进去2.5 连接
让别的机器也能用这个Gateway5.2 安全与对外提供服务
在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.

本页内容