feat: add Bedrock OpenAI channel type for GPT-5.5/5.4 - #5375
Conversation
WalkthroughThis pull request integrates Amazon Bedrock OpenAI as a new upstream channel type (58). The change adds constant definitions, wires the channel through existing API-type and endpoint-type lookups, defines Bedrock-specific GPT-5 model metadata, configures request routing to enforce the Responses API, adds pricing ratios, and updates both classic and modern frontend UIs to support the new channel type. ChangesBedrock OpenAI Channel Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@relay/channel/openai/bedrock_openai.go`:
- Around line 12-15: BedrockOpenAIModelList currently lists only
"openai.gpt-5.5" and "openai.gpt-5.4" but your pricing/cache tables reference
"openai.gpt-5.4-nano"; update consistency by either adding "openai.gpt-5.4-nano"
to the BedrockOpenAIModelList (if the model is supported) or removing/justifying
the "openai.gpt-5.4-nano" entries from setting/ratio_setting/model_ratio.go and
setting/ratio_setting/cache_ratio.go; locate the variable BedrockOpenAIModelList
and the model_ratio/cache_ratio maps and make the change so model names match
across all three places.
In `@setting/ratio_setting/cache_ratio.go`:
- Around line 39-47: Model IDs listed in ModelList ("gpt-5.4-pro",
"gpt-5.4-pro-2026-03-05", "gpt-5.5-codex") have no corresponding entries in the
ratio maps, causing missing configuration when selected; add matching entries to
the ratio maps (both cache_ratio and model_ratio) for those exact keys (and
dated variant) with the appropriate numeric ratios (e.g., same 0.1 value used
for similar models) so lookups succeed, or alternatively remove/disable those
IDs from ModelList until ratios are available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6f44b031-c6ed-4fef-8562-b8758b5d2810
📒 Files selected for processing (16)
common/api_type.gocommon/endpoint_type.goconstant/channel.gocontroller/channel-test.gorelay/channel/openai/adaptor.gorelay/channel/openai/bedrock_openai.gorelay/channel/openai/constant.gorelay/common/relay_info.goservice/openaicompat/policy.gosetting/ratio_setting/cache_ratio.gosetting/ratio_setting/model_ratio.goweb/classic/src/constants/channel.constants.jsweb/classic/src/helpers/render.jsxweb/default/src/features/channels/constants.tsweb/default/src/features/channels/lib/channel-type-config.tsweb/default/src/features/channels/lib/channel-utils.ts
| var BedrockOpenAIModelList = []string{ | ||
| "openai.gpt-5.5", | ||
| "openai.gpt-5.4", | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for gpt-5.4-nano references to confirm Bedrock availability
# Check for any Bedrock + nano references
rg -i 'bedrock.*nano|nano.*bedrock' -C3
# Check for openai.gpt-5.4-nano usage
rg -n 'openai\.gpt-5\.4-nano' -C2Repository: QuantumNous/new-api
Length of output: 1450
Align Bedrock OpenAI built-in model list with existing openai.gpt-5.4-nano pricing
relay/channel/openai/bedrock_openai.go’s BedrockOpenAIModelList only includes "openai.gpt-5.5" and "openai.gpt-5.4", but setting/ratio_setting/model_ratio.go and setting/ratio_setting/cache_ratio.go both already define pricing/cache entries for "openai.gpt-5.4-nano". Add "openai.gpt-5.4-nano" to the Bedrock model list if it’s supported, or remove/justify the ratio entries if not.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@relay/channel/openai/bedrock_openai.go` around lines 12 - 15,
BedrockOpenAIModelList currently lists only "openai.gpt-5.5" and
"openai.gpt-5.4" but your pricing/cache tables reference "openai.gpt-5.4-nano";
update consistency by either adding "openai.gpt-5.4-nano" to the
BedrockOpenAIModelList (if the model is supported) or removing/justifying the
"openai.gpt-5.4-nano" entries from setting/ratio_setting/model_ratio.go and
setting/ratio_setting/cache_ratio.go; locate the variable BedrockOpenAIModelList
and the model_ratio/cache_ratio maps and make the change so model names match
across all three places.
| "gpt-5.4": 0.1, | ||
| "gpt-5.4-2026-03-05": 0.1, | ||
| "gpt-5.4-nano": 0.1, | ||
| "gpt-5.5": 0.1, | ||
| "gpt-5.5-2026-04-23": 0.1, | ||
| "gpt-5.5-chat-latest": 0.1, | ||
| "openai.gpt-5.4": 0.1, | ||
| "openai.gpt-5.4-nano": 0.1, | ||
| "openai.gpt-5.5": 0.1, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for gpt-5.4-pro and gpt-5.5-codex references
# Check for gpt-5.4-pro
rg -n 'gpt-5\.4-pro' --type go -C2
# Check for gpt-5.5-codex
rg -n 'gpt-5\.5-codex' --type go -C2Repository: QuantumNous/new-api
Length of output: 808
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate ratio setting files
fd -t f 'cache_ratio.go' -a . || true
fd -t f 'model_ratio.go' -a . || true
# Search pricing maps for the missing model IDs
rg -n 'gpt-5\.4-pro' --glob='**/*cache_ratio.go' --glob='**/*model_ratio.go' || true
rg -n 'gpt-5\.5-codex' --glob='**/*cache_ratio.go' --glob='**/*model_ratio.go' || true
# Broader search in ratio_setting directory (any go/json/ts/yaml, etc.)
rg -n 'gpt-5\.4-pro' --glob='**/ratio_setting/**' || true
rg -n 'gpt-5\.5-codex' --glob='**/ratio_setting/**' || trueRepository: QuantumNous/new-api
Length of output: 175
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search within the two ratio maps
echo "== cache_ratio.go: gpt-5.4-pro / gpt-5.5-codex =="
rg -n 'gpt-5\.4-pro|gpt-5\.5-codex' setting/ratio_setting/cache_ratio.go || true
echo "== model_ratio.go: gpt-5.4-pro / gpt-5.5-codex =="
rg -n 'gpt-5\.4-pro|gpt-5\.5-codex' setting/ratio_setting/model_ratio.go || true
# Search within ratio_setting dir for any other references
echo "== ratio_setting dir: gpt-5.4-pro / gpt-5.5-codex =="
rg -n 'gpt-5\.4-pro|gpt-5\.5-codex' setting/ratio_setting || trueRepository: QuantumNous/new-api
Length of output: 216
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== full repo references (any file type) =="
rg -n 'gpt-5\.4-pro|gpt-5\.5-codex' . --glob='*' --glob='!node_modules/**' --glob='!vendor/**' || true
echo "== keys present in cache_ratio.go (near map entries for gpt-5.4 / openai.) =="
rg -n '"gpt-5\.[0-9]+\.[a-z0-9\-]+"' setting/ratio_setting/cache_ratio.go || true
rg -n '"openai\.gpt-5\.[0-9]+\.[a-z0-9\-]+"' setting/ratio_setting/cache_ratio.go || true
echo "== keys present in model_ratio.go (near map entries for gpt-5.4 / openai.) =="
rg -n '"gpt-5\.[0-9]+\.[a-z0-9\-]+"' setting/ratio_setting/model_ratio.go || true
rg -n '"openai\.gpt-5\.[0-9]+\.[a-z0-9\-]+"' setting/ratio_setting/model_ratio.go || true
echo "== openai constant ModelList includes these IDs? =="
rg -n 'ModelList|gpt-5\.4-pro|gpt-5\.5-codex' relay/channel/openai/constant.go || trueRepository: QuantumNous/new-api
Length of output: 544
Add missing cache/model ratio entries for gpt-5.4-pro* and gpt-5.5-codex
relay/channel/openai/constant.goincludes"gpt-5.4-pro","gpt-5.4-pro-2026-03-05", and"gpt-5.5-codex"inModelList.setting/ratio_setting/cache_ratio.goandsetting/ratio_setting/model_ratio.gocontain no corresponding entries for these IDs, so selecting them will lack configured ratios.
Either add the missing ratio entries for these model IDs (including dated variants) or remove/disable them from ModelList until pricing/ratios are available.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setting/ratio_setting/cache_ratio.go` around lines 39 - 47, Model IDs listed
in ModelList ("gpt-5.4-pro", "gpt-5.4-pro-2026-03-05", "gpt-5.5-codex") have no
corresponding entries in the ratio maps, causing missing configuration when
selected; add matching entries to the ratio maps (both cache_ratio and
model_ratio) for those exact keys (and dated variant) with the appropriate
numeric ratios (e.g., same 0.1 value used for similar models) so lookups
succeed, or alternatively remove/disable those IDs from ModelList until ratios
are available.
51fdfc5 to
2b6f1df
Compare
Adds a dedicated Bedrock OpenAI channel type (58) for OpenAI frontier models (GPT-5.5, GPT-5.4) hosted on Amazon Bedrock via the bedrock-mantle endpoint. The new channel reuses the existing OpenAI adaptor (APITypeOpenAI) but ships with a built-in model list, a default base URL, and automatic ChatCompletions-to-Responses routing, so users can connect without any manual global configuration.
Motivation
AWS recently made OpenAI GPT-5.5 and GPT-5.4 generally available on Amazon Bedrock through the bedrock-mantle endpoint. These models are OpenAI-compatible but with an important constraint:
GPT-5.5 on Bedrock supports only the Responses API — not /v1/chat/completions.
GPT-5.4 supports both Responses and Chat Completions.
A standard OpenAI channel therefore fails for GPT-5.5 with The model 'openai.gpt-5.5' does not support the '/v1/chat/completions' API. This PR makes it work out of the box.
What this PR does
New channel type ChannelTypeBedrockOpenAI = 58, mapped to APITypeOpenAI.
Default base URL https://bedrock-mantle.us-east-2.api.aws/openai (no trailing /v1).
Built-in model list: openai.gpt-5.5, openai.gpt-5.4.
Automatic ChatCompletions → Responses routing for this channel type, so clients keep using /v1/chat/completions while GPT-5.5 is served via the Responses API.
Channel test defaults to the Responses endpoint (same as Codex).
Pricing: model / cache / completion ratios for gpt-5.4, gpt-5.5 and their openai.-prefixed IDs (GPT-5.5 $5/$30, GPT-5.4 $2.5/$15 per 1M).
Frontend: registers the type in both default and classic UIs.
Testing
Verified end-to-end against a real Bedrock API key (us-east-2):
✅ Channel "Test connection" passes
✅ Non-streaming for both openai.gpt-5.5 and openai.gpt-5.4
✅ Streaming (SSE) with final usage block
✅ Token usage billed correctly
✅ go build ./... passes; both frontends show the new type
Notes
GPT-5.5 is only in us-east-2; GPT-5.4 in us-east-2 and us-west-2.
GPT-5.5 is a reasoning model; very short prompts may occasionally return empty completions (upstream behavior).
Summary by CodeRabbit
New Features
openai.prefix)