Apache Casbin Gateway
3. 供应商

3.4 真伪检测

中转商可以卖你旗舰模型、给你一个更便宜的;可以把命中缓存的前缀按新输入计费;也可以用一套它只是假装会说的API来回答你。这些在流量里都看不出来。

真伪检测直接去问上游,给出百分制分数和A到F的等级。

真伪检测

不用你按任何按钮

每个供应商都会被自动探测:

  • 刚添加时,
  • 端点、类型或Key变更时,
  • 从来没探过时,
  • 以及报告过期之后。

等级显示在真伪检测页上,也显示在首页Agent的上方。

设置默认效果
providerProbeModeautomanual只在你要求时探测;off从不探测
providerProbeIntervalHours—多久之后报告算过期

一次探测会花掉这个供应商自己账上几分钱,报告里会写在结论旁边。

测试用例在问什么

分数只是它背后那些用例的汇总,而每一个用例都摊在测试用例标签页上:它向上游提的问题、发出去的确切请求、如何判定答案、以及它值多少分。

测试用例

一半用例在问上游到底是什么:

  • 回答的模型是不是你点名的那个——在厂商自己的端点上只给一半分,因为那个字段本来就是上游想写什么就写什么。
  • 模型自己说是哪家训练的。
  • 请求前面有没有被塞东西。
  • 多次完全相同的请求,回来的是不是同一个模型。
  • API文档里写明的参数(logprobs、n、停止序列)是被遵守了、被拒绝了,还是返回200之后悄悄丢掉了。
  • 一组只有唯一正确答案的题库,从数一个单词里的字母,到《滕王阁序》是谁写的。

另一半在读信封:

  • 两层嵌套的工具schema在强制调用下还在不在。
  • 事件流是不是带齐了API文档规定的内容。
  • 提示词缓存有没有被如实计费。
  • 两个完全相同的请求,账单是不是一样。
  • 厂商自己的响应头在不在。

改成你自己的

可以调整某个用例的权重、关掉它、重写它的问题,或者加一个你自己的。该问中转商什么,各行各业不一样;而一个不公开方法的分数不算证据。

恢复默认会把内置的那套装回来,你自己加的用例原样保留。

不花钱的那一半

报告还有一半完全不发请求:Gateway已经存下来的记录能说明这个上游什么——

  • 它到底如实计入了多少缓存,
  • 有多少次尝试失败了,
  • 回答花了多长时间,
  • 以及它提供的东西里有多少是没有价格的。

下一节:3.5 导入配置与链接。

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

本页内容