Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
botOpened by the maintenance botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidateQuantumNous/new-api upstream commit port candidate
Description
上游来源
- 仓库:QuantumNous/new-api
- 提交:
d0322047— feat(aws): add Mantle Messages API support(Refs QuantumNous/new-api#4791) - 时间:2026-10-16 14:45 台北(committer)
- 对比基线:
ca2cae67→d0322047(1 个提交) - 统计:+834/−3(后端 4 个文件,其中测试 +426;前端 channels 表单 + 7 个语言包)
做什么 / 为什么
AWS Bedrock 新增的 Mantle 端点(https://bedrock-mantle.<region>.api.aws/anthropic/v1/messages)直接接受原生 Anthropic Messages JSON / SSE,而不是 InvokeModel 的封装格式。上游把它做成 AWS 渠道的可选接口,默认仍走 InvokeModel:
ChannelOtherSettings新增aws_api_type(invoke_model默认 /mantle)。- 新文件
relay/channel/aws/mantle.go:- 密钥格式
APIKey|Region(发x-api-key)或AccessKey|SecretAccessKey|Region(SigV4 签名,且会删掉无关的Authorization/x-api-key) - 校验 region 字符集、自定义 base URL 必须是 https 且不带凭据/查询/fragment,自动补全
/anthropic/v1/messages - 模型名强制使用渠道解析后的
UpstreamModelName,claude-*加anthropic.前缀,claude-haiku-4-5-20251001映射为claude-haiku-4-5;不套 InvokeModel 的版本后缀和跨区前缀;Nova 模型直接拒绝 - 删除 body 中的
anthropic_version/anthropic_beta,改用 header;在 header override 之后剔除 hop-by-hop 头再签名,保证 SigV4 覆盖的头与实际发出的一致(HTTP/1.1 与 HTTP/2 均有测试)
- 密钥格式
adaptor.go:GetRequestURL/DoRequest按AwsApiType分支,未知值报错;DoResponse对 Mantle 复用 Claude 原生响应处理,因此顶层cache_control与缓存用量可以正常透传和计费。- 前端
channel-mutate-drawer.tsx/channel-form.ts为类型 33(AWS)增加接口选择,非 AWS 渠道会清掉aws_api_type;7 个语言包各 +4 条。
对 LMM 的意义:Bedrock 上的 Claude 走 InvokeModel 时缓存控制和新参数支持受限,Mantle 能让 Bedrock Claude 渠道的行为和计费接近直连 Anthropic;而且是 opt-in,不影响现有渠道。
LMM 现状(已核)
- 冻结的
main@3948a0a1:apps/api-go/relaykit/dto/channel_settings.go已有AwsKeyType(ak_sk/api_key),但没有AwsApiType;apps/api-go/relay/channel/aws/adaptor.go里没有ClientModeApiKey分支(上游 Mantle 分支就插在这个分支前面),所以移植时需先确认 fork 的 API Key 模式是否完整,或只移植 Mantle 的 SigV4 路径。 - 默认分支
wip/rust-core-go-extensions:代码搜索bedrock/mantle在非 web 代码中无命中,Rust core 目前没有 AWS 渠道;落地路径以届时 Go 网关树为准。 - 已有 issue 中没有 Mantle 相关项([upstream-idea] Responses 响应 ID(previous_response_id / response_id)按租户绑定归属,防止共享上游 key 下跨用户续接(litellm) #914 只在 litellm 的 N/A 表里提到过 Bedrock Mantle)。
路径映射
| 上游路径 | LMM 候选 |
|---|---|
relay/channel/aws/mantle.go(新) |
apps/api-go/relay/channel/aws/mantle.go |
relay/channel/aws/adaptor.go |
apps/api-go/relay/channel/aws/adaptor.go |
relay/channel/aws/relay_aws_test.go |
同路径(fork 已有该测试文件,需合并) |
relaykit/dto/channel_settings.go |
apps/api-go/relaykit/dto/channel_settings.go |
web/src/features/channels/components/drawers/channel-mutate-drawer.tsx |
apps/web/src/features/channels/components/drawers/channel-mutate-drawer.tsx |
web/src/features/channels/lib/channel-form.ts、types.ts、新测试 aws-channel.test.ts |
apps/web/src/features/channels/lib/… |
web/src/i18n/locales/*.json |
apps/web/src/i18n/locales/*.json |
风险 / 冲突
- 计费:Mantle 走 Claude 原生
DoResponse,缓存读写 token 会按 Claude 规则计入;需确认与 fork 的 1 USD = 500000 credits 固定换算和钱包上下限一致,不能出现缓存用量漏计或重复计费。 - 安全:SigV4 必须签最终发出的 payload 和 header(包括管理员 header override);不要把
Proxy-Authorization等代理凭据发给 AWS。移植时保留上游这部分逻辑和测试。 - 依赖:需要
aws-sdk-go-v2/aws/signer/v4;fork 现有 AWS 适配器已用 aws-sdk-go-v2,核对版本即可。 - 与支付、订阅、assistant、HeroSMS、悬赏契约、Redis-off 运行时、task/JS plugin host 决定无直接冲突。
- 前端部分必须由 Opus 5.5(claude-opus-5-5)云端 agent 完成,并保持 LMM 品牌和 DESIGN.md;当前 Cursor 云端 agent 额度已用完,本轮只建 issue。
测试建议
cd apps/api-go && go test ./relay/channel/aws/...(移植上游的 Mantle URL、SigV4 over HTTP/1.1/HTTP/2、cache 用量、旧渠道仍走 InvokeModel、非法aws_api_type报错等用例)cd apps/web && bun test(或仓库约定的命令)跑channel-configuration.test.tsx和aws-channel.test.ts- 手工:AWS 渠道切到 Mantle,分别用
APIKey|Region与AK|SK|Region发一次流式和非流式请求,确认缓存用量和扣费;未配置aws_api_type的老渠道行为不变
工作量
中:后端约 3–4 小时(含测试与 API Key 模式核对);前端约 1–2 小时(Opus 5.5)。
Metadata
Metadata
Assignees
Labels
botOpened by the maintenance botOpened by the maintenance botupstream-portQuantumNous/new-api upstream commit port candidateQuantumNous/new-api upstream commit port candidate
Activity
LIghtJUNction commentedon Nov 14, 2026
本 Issue 已合并到 #987 统一跟踪:#987
本次关闭仅用于合并去重,不代表问题已修复、已验收或放弃处理。原始正文和讨论仍保留在这里,后续实现与验收请使用新 Issue。