Skip to content

feat: add Bedrock OpenAI channel type for GPT-5.5/5.4 - #5375

Open
yingfengli wants to merge 1 commit into
QuantumNous:mainfrom
yingfengli:feat/bedrock-openai-channel
Open

feat: add Bedrock OpenAI channel type for GPT-5.5/5.4#5375
yingfengli wants to merge 1 commit into
QuantumNous:mainfrom
yingfengli:feat/bedrock-openai-channel

Conversation

@yingfengli

@yingfengli yingfengli commented Jun 8, 2026

Copy link
Copy Markdown

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

  • Added Amazon Bedrock OpenAI channel type now available for configuration
  • Added support for new OpenAI models: GPT-5.4 and GPT-5.5 (including Bedrock-hosted variants with openai. prefix)
  • Configured pricing and cache ratios for all new models
  • Updated web interface to display and configure the Bedrock OpenAI channel with setup hints and supported model identifiers

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

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

Changes

Bedrock OpenAI Channel Support

Layer / File(s) Summary
Channel type definition and core routing
constant/channel.go, common/api_type.go, common/endpoint_type.go, relay/common/relay_info.go
Introduces ChannelTypeBedrockOpenAI = 58 constant with default base URL pointing to Bedrock Mantle endpoint (us-east-2) and display name; routes to APITypeOpenAI, both EndpointTypeOpenAI and EndpointTypeOpenAIResponse, and marks as supporting streams.
OpenAI relay model list and adaptor support
relay/channel/openai/bedrock_openai.go, relay/channel/openai/constant.go, relay/channel/openai/adaptor.go
Defines BedrockOpenAIModelList with Bedrock-hosted frontier model IDs (openai.gpt-5.5, openai.gpt-5.4) and BedrockOpenAIChannelName; extends OpenAI ModelList with GPT-5.5 variants and Bedrock model IDs; integrates both into adaptor's GetModelList and GetChannelName methods.
Endpoint routing and Responses API policy
controller/channel-test.go, service/openaicompat/policy.go
Defaults Bedrock OpenAI test endpoints to EndpointTypeOpenAIResponse when endpoint type is not explicitly provided; unconditionally routes Bedrock OpenAI chat completions through the Responses API policy (GPT-5.5 supports only Responses API).
Cache and model ratio configuration
setting/ratio_setting/cache_ratio.go, setting/ratio_setting/model_ratio.go
Adds cache ratios (0.1) for all GPT-5.4/GPT-5.5 variants and Bedrock openai.* models; extends model and completion ratios with pricing multipliers for GPT-5 family models and their Bedrock equivalents.
Classic web UI channel option and icon
web/classic/src/constants/channel.constants.js, web/classic/src/helpers/render.jsx
Adds Bedrock OpenAI to CHANNEL_OPTIONS with green color indicator; maps channel type 58 to OpenAI icon in getChannelIcon.
Default web UI channel type config and display
web/default/src/features/channels/constants.ts, web/default/src/features/channels/lib/channel-type-config.ts, web/default/src/features/channels/lib/channel-utils.ts
Adds CHANNEL_TYPES[58] entry, includes in display order immediately after type 1; defines Bedrock Mantle endpoint configuration with base URL, hints for API key and base URL format, and supported model identifiers; maps channel type 58 to OpenAI icon.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • QuantumNous/new-api#2875: Refactors normalizeChannelTestEndpoint to infer endpoint types when omitted; this PR extends it with Bedrock OpenAI-specific defaulting logic.
  • QuantumNous/new-api#3221: Also extends relay/channel/openai/constant.go model list with new OpenAI model identifiers; overlaps at model-list definition level.
  • QuantumNous/new-api#1525: Modifies GPT-5 completion ratio logic in setting/ratio_setting/model_ratio.go for pricing configuration consistency.

Suggested reviewers

  • seefs001

Poem

🐰 A new Bedrock path blooms today,
OpenAI models find their way,
Through constant routes and ratios true,
Frontend glows with Bedrock blue,
Amazon's frontier reaches you! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a new Bedrock OpenAI channel type with support for GPT-5.5/5.4 models.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca47ee and 0e0d4f8.

📒 Files selected for processing (16)
  • common/api_type.go
  • common/endpoint_type.go
  • constant/channel.go
  • controller/channel-test.go
  • relay/channel/openai/adaptor.go
  • relay/channel/openai/bedrock_openai.go
  • relay/channel/openai/constant.go
  • relay/common/relay_info.go
  • service/openaicompat/policy.go
  • setting/ratio_setting/cache_ratio.go
  • setting/ratio_setting/model_ratio.go
  • web/classic/src/constants/channel.constants.js
  • web/classic/src/helpers/render.jsx
  • web/default/src/features/channels/constants.ts
  • web/default/src/features/channels/lib/channel-type-config.ts
  • web/default/src/features/channels/lib/channel-utils.ts

Comment on lines +12 to +15
var BedrockOpenAIModelList = []string{
"openai.gpt-5.5",
"openai.gpt-5.4",
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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' -C2

Repository: 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.

Comment on lines +39 to +47
"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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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 -C2

Repository: 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/**' || true

Repository: 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 || true

Repository: 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 || true

Repository: 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.go includes "gpt-5.4-pro", "gpt-5.4-pro-2026-03-05", and "gpt-5.5-codex" in ModelList.
  • setting/ratio_setting/cache_ratio.go and setting/ratio_setting/model_ratio.go contain 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant