Apache Casbin Gateway
3. 供应商

3.1 供应商

一个供应商就是Gateway可以把Agent请求发过去的一个模型端点:官方厂商、中转商,或者跑在本机上的东西。供应商页就是它们的列表。

新增供应商

新增

供应商→新增:

字段填什么
类型这个端点说哪套API:OpenAI、Anthropic、OpenAI Responses,或者Custom——其他任何OpenAI兼容的端点
基础URL厂商的端点,照它自己文档给的填
API KeyGateway用来认证的Key——没有Key的情况见3.3
模型它提供的模型。留空则接受任意模型名
认证方式用上面这个Key,或者调用方自己的登录(3.3)
上游接口Gateway调用它时用哪个端点。除非厂商另有说明,保持按类型推断即可

存之前Gateway会先测一遍这个端点,此后真伪检测会自动给它打分。

有些厂商在自己页面上放了"添加此供应商"的按钮,可以跳过这张表单,见3.5 导入配置与链接。

类型不是限制

类型说的是供应商说哪套API,不是你的Agent必须说哪套。Gateway在四套API之间双向转换,所以一个OpenAI兼容的供应商完全可以服务Anthropic客户端(3.2)。

也就是说,对大多数中转商,答案就是:它文档里写的是OpenAI还是Anthropic,就选哪个。

厂商同时提供Responses接口时

上游接口在新增表单的高级里,供应商自己的页面上也有。它决定Gateway往基础URL后面接哪个路径:/chat/completions、/responses还是/v1/messages。按类型推断给OpenAI兼容的供应商选第一个,给Anthropic的选最后一个,对绝大多数厂商都是对的。

如果这个端点同时也提供Responses接口,就把它设成Responses。类型选OpenAI Responses是同一件事,只是一开始就选好:用OpenAI的基础URL和模型,调用/responses。有两个理由:

  • Codex客户端本来就说这套。两头都是Responses时,请求原样转发,不必来回翻译两次,规范形式没建模的东西也就不会丢。
  • 有些中转商在/responses上报的缓存命中比在/chat/completions上准。这样缓存数就按上游给的原样进入LLM记录,按缓存价而不是完整输入价计费。

这个设置只影响Gateway发往上游的请求,Agent那边该说哪套还说哪套。

只要有端点就行

有四十来家厂商和网关是按名字认得的,其他任何说得通这两套API的东西,用法完全一样:

  • 官方厂商——OpenAI、Anthropic、Google Gemini、xAI、Mistral、Cohere、DeepSeek、月之暗面、智谱GLM、MiniMax、阶跃星辰、百川等等。
  • 聚合平台——OpenRouter、硅基流动、Together、Groq、Fireworks、Novita、PPIO、AiHubMix、302.AI、Vercel AI Gateway。
  • 云厂商——Bedrock类端点、阿里云百炼、火山引擎、腾讯云、百度、魔搭、NVIDIA NIM。
  • 本地——Ollama、LM Studio、vLLM、llama.cpp、LiteLLM。

Key存在哪

存在Gateway自己的数据库里,就在这台机器上。有两件事值得做:

  • apiKeyEncryptionKey用AES-256-GCM把供应商的API Key加密落盘(5.1)。
  • Key不会进记录:请求头根本不存,正文在落库前会被脱敏(4.2)。

流量走Gateway的Agent压根拿不到Key——它拿到的是Gateway自己的中继令牌(3.2)。

哪个Agent能用哪个供应商

按Agent设置,在权限页:任意供应商,或只允许你勾的那几个(4.1)。

下一节:3.2 让Agent的流量走Gateway。

在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.

本页内容