new-api
new-api copied to clipboard
支持 Cloudflare AI Gateway 格式的 Workers AI 请求 URL
例行检查
- [x] 我已确认目前没有类似 issue
- [x] 我已确认我已升级到最新版本
- [x] 我已完整查看过项目 README,尤其是常见问题部分
- [x] 我理解并愿意跟进此 issue,协助测试和提供反馈
- [x] 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭
问题描述 Workers AI Endpoint:
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model_id}
AI Gateway Endpoint:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/workers-ai/{model_id}
其他请求方式和Workers AI完全相同。
解决方法可以是:
- 基于现有的Cloudflare渠道,判断域名是不是gateway.ai.cloudflare.com,作特殊处理(推荐);
- 新增一个名字类似 Cloudflare AI (with Gateway) 的渠道,设置项只需要API地址(从 AI Gateway 后台粘贴即可)和密钥。
复现步骤 将Gateway API Endpoint填入Cloudflare渠道 预期结果 可兼容此格式的URL
补充:根据Cloudflare官方,AI Gateway Endpoint为新端点,应该迁移至新端点
考虑到兼容性问题,推荐的解决方案是将原有的Cloudflare渠道更名为Workers AI,并在设置中新增一个选填的gateway_id参数,如果填写则请求:
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/workers-ai/{model_id}
否则请求旧Endpoint:
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model_id}
另新增一个新的Cloudflare AI Gateway渠道,从新Endpoint发出请求,此渠道gateway_id为必填参数
旧的Workers AI渠道专注于Cloudflare Workers AI 上的 Serverless Inference 模型,而新的Cloudflare AI Gateway则可以通过 AI Gateway 反代调用所有支持的模型和供应商