Skip to content

fix(relay): allow Azure channels to opt in to Responses WebSocket (#8047) - #8075

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/azure-responses-websocket-8047
Oct 28, 2026
Merged

seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/azure-responses-websocket-8047

Conversation

@seefs001

Copy link
Copy Markdown
Collaborator

Agent

  • Tool: Claude Code
  • Tool version: 2.1.302.808
  • Model (full id): claude-opus-5-5
  • Host (CLI / IDE / GitHub coding agent / other): CLI via Paseo
  • Date (UTC): 2026-10-28

Links

User request

  • Verbatim:

Fix GitHub #8047 and open a PR.

Bug

Azure channel (ChannelTypeAzure = 3) cannot serve GET /v1/responses WebSocket:

  1. model/channel_constraint.go FilterResponsesWebSocket only allows OpenAI/Codex/Sub2API/NewAPI/AdvancedCustom — Azure returns false → 503 model_not_found
  2. web/src/features/channels/lib/channel-form.ts supportsResponsesWebSocket excludes Azure — UI cannot enable responses_websocket_enabled
  3. relay/responses_websocket.go openResponsesWSUpstream has no Azure URL branch

Upstream Azure OpenAI / Foundry supports wss://.../openai/v1/responses?api-version=.... Clients (e.g. OpenCode) upgrade 101 then send response.create and cannot fall back to HTTP POST.

Expected fix (opt-in; default still off)

  • Allow Azure to enable responses_websocket_enabled across FilterResponsesWebSocket, supportsResponsesWebSocket UI, and openResponsesWSUpstream Azure URL (api-key / api-version / path aligned with existing Azure HTTP)
  • When the option is off: same as today — WS channel selection skips Azure; HTTP POST unchanged
  • Keep the diff small; add unit tests if practical, or document why live Azure WS cannot be tested locally and what equivalent verification you ran
  • Later constraints or corrections from the user (quote, or none): none

Out of scope — refuse

  • Matched: no
  • If yes, what was told to the user (stop here; do not open a PR): not applicable

Open gate — do not open unless all are satisfied

  • Out of scope (including pass-through-only forwarding): no
  • Usage / configuration / integration (answered instead of opening): no
  • Required issue facts present without invention: yes
  • Verification is actual commands or steps and observed results, not only go build or tests passed: yes
  • Body is short and factual; no unfiltered AI-generated text: yes
  • Open: yes
  • If no, what was told to the user (stop here): not applicable

Kind

  • Bug fix
  • New feature
  • Performance / refactor
  • Docs
  • Other:

Issue facts

  • Actual behavior: GET /v1/responses (WebSocket) upgrades with 101, then the first response.create returns 503 model_not_found when the model is served only by an Azure channel (type 3).
  • Impact: clients that use WebSocket for /v1/responses by default (OpenCode 2.0 in the report) cannot fall back to HTTP POST after the 101 upgrade.
  • Frequency: every request, per the issue.
  • Evidence that the problem is in new-api rather than the client or upstream: the issue shows the same response.create sent directly to wss://<resource>.openai.azure.com/openai/v1/responses?api-version=... returns response.created. In new-api, channelMatchesFilter for FilterResponsesWebSocket returns false for type 3, and the channel form hides the toggle for type 3.
  • Applicable types and their fields: relay: endpoint GET /v1/responses (WebSocket), channel type Azure (3), native Responses WebSocket, pass-through disabled. Frontend: channel form responses_websocket_enabled toggle. Billing and deployment: not applicable.

Change

  • model/channel_constraint.go: add ChannelTypeAzure to the FilterResponsesWebSocket allow list. The ResponsesWebSocketEnabled check before the type switch is unchanged, so Azure still needs the per-channel opt-in.
  • web/src/features/channels/lib/responses-websocket.ts: add type 3 to RESPONSES_WEBSOCKET_CHANNEL_TYPES so the form shows and saves the toggle for Azure.
  • No relay URL change. The issue names openResponsesWSUpstream, which does not exist on main. The WebSocket session dials through relaychannel.DoWssRequest, which calls the adaptor's GetRequestURL and SetupRequestHeader and maps https to wss. Azure resolves to the OpenAI adaptor, whose RelayModeResponses branch already builds /openai/v1/responses?api-version=<preview | AzureResponsesVersion> (or /openai/responses?api-version=<channel api version> for cognitiveservices.azure.com) and sets api-key without Authorization. The WebSocket path therefore reuses the Azure HTTP Responses URL and auth.

Research

Duplicate / prior art

Docs and code

  • https://docs.newapi.ai/ : the homepage does not mention Responses WebSocket or responses_websocket_enabled.
  • https://deepwiki.com/QuantumNous/new-api : the fetch returned HTTP 429, so it was not read.
  • README / repo docs: no Responses WebSocket channel list.
  • Code paths and what they imply for this change: relay/responses_websocket.go runCall → selectResponsesWSChannel (adds FilterResponsesWebSocket) → relaychannel.DoWssRequest (relay/channel/api_request.go) → openai.Adaptor.GetRequestURL / SetupRequestHeader (relay/channel/openai/adaptor.go). middleware.SetupContextForSelectedChannel sets api_version from channel.Other for Azure, which GenRelayInfo reads into ApiVersion. restoreConnectionContext rechecks ResponsesWebSocketEnabled on every later response.create.

Alternatives considered

  • Option A: add a separate Azure URL builder on the WebSocket path. This would duplicate the adaptor's Azure Responses URL logic and could drift from HTTP.
  • Option B: bridge WebSocket response.create to upstream HTTP SSE (issue alternative 2). This is a larger, directional change.
  • Why this approach: the dial path already uses the adaptor, so allowing the type is the smallest change that keeps WebSocket and HTTP URL and auth identical.

Files

Path Why
model/channel_constraint.go Allow Azure in FilterResponsesWebSocket
web/src/features/channels/lib/responses-websocket.ts Show and save the toggle for type 3
relay/responses_websocket_test.go Azure selection case; Azure dial URL / api-version / api-key test
web/src/features/channels/components/__tests__/responses-websocket-setting.test.tsx Add type 3 to the supported types table

Behavior

  • Before: Azure channels were never selected for /v1/responses WebSocket, and the form had no toggle for them.
  • After: an Azure channel with responses_websocket_enabled: true is selectable and dials wss://<base>/openai/v1/responses?api-version=... with api-key. With the option off (the default), WebSocket selection still skips it. HTTP POST /v1/responses is unchanged.
  • Explicit non-goals / leftover work: no HTTP SSE bridge for WebSocket clients and no early rejection of the upgrade when no WebSocket channel exists (issue alternative 2).

Verification

  • Commands and results:
    • Backend red/green: git stash push -- model/channel_constraint.go && go test ./relay/ -run TestSelectResponsesWSChannelAcceptsNativeResponsesChannelTypes -count=1 → --- FAIL: .../azure. After git stash pop, the same test plus TestResponsesWSAzureDial → ok github.com/QuantumNous/new-api/relay.
    • go test ./relay/ -run 'TestResponsesWSAzureDial|TestSelectResponsesWSChannelAcceptsNativeResponsesChannelTypes|TestResponsesWSChannelRoutingRequiresExplicitOptIn' -count=1 -v → all subtests PASS: openai_v1_default_preview, channel_responses_version, cognitiveservices_uses_channel_api_version, and the selection subtests including azure.
    • go build ./... && go vet ./relay/ ./model/ && go test ./relay/ ./model/ ./relay/channel/openai/ ./relay/channel/ -count=1 → ok for all four packages.
    • Frontend red/green: with only responses-websocket.ts stashed, bunx vitest run src/features/channels/components/__tests__/responses-websocket-setting.test.tsx → Tests 2 failed | 25 passed (27) (the type 3 cases). After restoring → Tests 27 passed (27).
    • bunx tsc -b → exit 0. bunx oxlint -c .oxlintrc.json <2 changed web files> → exit 0. bunx oxfmt -c .oxfmtrc.json --check <2 changed web files> → All matched files use the correct format. gofmt -l <2 changed Go files> → no output.
  • Manual steps and observed result: none against a live Azure resource.
  • UI: screenshot or recording (or why none): none. The change only adds type 3 to an existing allow list. The component test renders the toggle for type 3, checks its accessible name Enable Responses WebSocket, and saves it on and off.
  • Tests added or updated, or why none: TestResponsesWSAzureDialUsesAzureResponsesURLAndAPIKey dials a local httptest WebSocket server through DoWssRequest with an Azure RelayInfo and asserts the handshake path, api-version, api-key, and no Authorization. An azure case was added to the existing selection table, and type 3 was added to the frontend supported types table. The existing TestResponsesWSChannelRoutingRequiresExplicitOptIn covers the off case, because the opt-in check runs before the type switch.
  • Databases / providers / platforms exercised: SQLite test DB in relay tests (no schema change); macOS, Go per go.mod, Bun 1.4.2.
  • Not verified: a live wss:// session to Azure OpenAI / Foundry (no Azure resource or key available locally). Azure's server-side WebSocket behavior, its event shapes, and accepted api-version values come from the issue report, not from a test here.

Risks

  • Failure modes: if an Azure deployment does not accept WebSocket on the configured api-version, the dial fails and goes through the existing retry and channel error handling. This only happens for channels where the operator enabled the option.
  • Billing / quota / auth impact: no billing code changed. Usage comes from the same Responses event handling used for the other WebSocket channel types. The Azure auth header is the one HTTP already uses.
  • Follow-ups: none planned.

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope (Coding Plan / reverse-engineered channel / third-party wrapper / Codex / pass-through-only forwarding): no

…antumNous#8047)

Azure channels with responses_websocket_enabled were rejected by
FilterResponsesWebSocket, and the channel form hid the toggle for type 3.
The OpenAI adaptor already builds the Azure /openai/v1/responses URL with
api-version and sets the api-key header, and DoWssRequest reuses both, so
no relay URL change is needed.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@seefs001
seefs001 merged commit 26c488c into QuantumNous:main Oct 28, 2026
2 checks passed
kyuhwi-choi pushed a commit to attodev/new-api that referenced this pull request Oct 30, 2026
…antumNous#8047) (QuantumNous#8075)

Azure channels with responses_websocket_enabled were rejected by
FilterResponsesWebSocket, and the channel form hid the toggle for type 3.
The OpenAI adaptor already builds the Azure /openai/v1/responses URL with
api-version and sets the api-key header, and DoWssRequest reuses both, so
no relay URL change is needed.

(cherry picked from commit 26c488c)
woncc added a commit to 86669666/new-api that referenced this pull request Nov 5, 2026
…antumNous#8047) (QuantumNous#8075) (#147)

Azure channels with responses_websocket_enabled were rejected by
FilterResponsesWebSocket, and the channel form hid the toggle for type 3.
The OpenAI adaptor already builds the Azure /openai/v1/responses URL with
api-version and sets the api-key header, and DoWssRequest reuses both, so
no relay URL change is needed.

(cherry picked from commit 26c488c)

Co-authored-by: Seefs <40468931+seefs001@users.noreply.github.com>
shirosoralumie648 added a commit to shirosoralumie648/newapi-rev that referenced this pull request Nov 5, 2026
Sync 75 upstream commit(s) via merge (fork history preserved).

Upstream commits:
- 7061447 fix(auth): 校验 Redis 鉴权缓存完整性 (QuantumNous#8200)
- ba5f736 fix(gemini): bill embeddings from upstream usageMetadata (QuantumNous#8182)
- 94b5216 feat(vertex): add per-channel v1beta1 endpoint switch (QuantumNous#8179)
- 83b18fe feat(channel): return created IDs with input mappings (QuantumNous#8164)
- 52c1730 feat(gemini): add Argon fields and reasoning mappings (QuantumNous#8177)
- 9b473a3 fix(twofa): restart the failure count after a lockout expires (QuantumNous#8172)
- 45746ee feat(relay): add opt-in HTTP/2 health checks (QuantumNous#8059)
- c046559 feat(plugins): bill gemini omni by the tokens vertex reports (QuantumNous#8153)
- 651d5a2 fix(xai): preserve token details in stream usage conversion (QuantumNous#6420)
- 70e6af6 perf: read and edit request JSON and base64 with moego (QuantumNous#8148)
- d0abbf6 feat(plugins): generate video with Gemini Omni on Vertex AI channels (QuantumNous#8142)
- ea343c4 fix(plugins): charge relayed streams even when the reserve or task insert fails (QuantumNous#8121)
- fe57cba fix(plugins): prefer Kling's returned price (list_price) for Kling 4.0 cash billing (QuantumNous#8125)
- 1424ffd fix(plugins): load plugins that declare their own /{key} address (QuantumNous#8119)
- 8b253de fix(plugins): keep Kling 4.0 durations in range and map every video size (QuantumNous#8118)
- c59f6fd feat(plugins): serve task plugins at the vendors' own paths and answer as the vendors do (QuantumNous#8117)
- 37d23dc fix(profile): honor global sidebar visibility (QuantumNous#7429)
- 7743627 fix(deps): upgrade DOMPurify to 3.4.17 (QuantumNous#8116)
- 883eeb8 feat(plugins): warn about task models a plugin cannot charge
- 1e8c707 chore(deps): bump @codemirror/language from 6.12.4 to 6.13.1 in /web (QuantumNous#8102)
- 6e78cb3 chore(deps): bump marked from 18.0.6 to 18.1.2 in /web (QuantumNous#8103)
- 9fc70bb chore(deps-dev): bump @tanstack/react-query-devtools in /web (QuantumNous#8104)
- cef7820 chore(deps-dev): bump knip from 6.27.0 to 6.43.0 in /web (QuantumNous#8105)
- 1695171 chore(deps): bump tailwind-merge from 3.6.0 to 3.7.0 in /web (QuantumNous#8106)
- 7fa815e chore(deps-dev): bump fast-uri from 3.1.7 to 3.1.9 in /electron (QuantumNous#8007)
- ee0f0ac chore(deps-dev): bump electron from 41.10.6 to 42.11.16 in /electron (QuantumNous#8008)
- 837b814 chore(deps): bump undici in /electron (QuantumNous#8006)
- 3150dfe chore(deps): bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6 (QuantumNous#8112)
- a3851c2 fix: save Turnstile keys before enabling (QuantumNous#7960)
- 4193734 fix(logger): keep gin access and recovery logs on the current log file after rotation (QuantumNous#8098)
- f366017 Merge commit from fork
- 829f082 fix: unmount authenticated layout on sign-out to stop credential-less refetches (QuantumNous#8110)
- 9eda50a Merge commit from fork
- a2defd2 Merge commit from fork
- e449cc7 feat: sample immediate task successes in model performance metrics (QuantumNous#8067)
- fcc241c fix: start affinity fallback at the highest channel priority (QuantumNous#8078)
- b08ee86 fix(cloudflare): preserve embedding response data (QuantumNous#8041)
- 26c488c fix(relay): allow Azure channels to opt in to Responses WebSocket (QuantumNous#8047) (QuantumNous#8075)
- 55515db fix(relay): terminate streams on exact bare done markers (QuantumNous#8074)
- 49271d2 fix(aws): preserve safeguards in Bedrock Invoke requests (QuantumNous#8071)
- 5478811 fix: count completed non-stream relays after context cancellation (QuantumNous#7844)
- ad56112 fix(relay): apply GPT-6 chat parameter rules to gpt-6.1-sol and gpt-6.1-terra (QuantumNous#8064)
- 01da3a5 perf(relay): stop recompiling param override regexes on every request (QuantumNous#8061)
- 34003e9 test: stabilize channel affinity cache keys (QuantumNous#8009)
- 0165fef fix(relaykit): preserve Gemini text alongside tool calls (QuantumNous#7998)
- 4d962e4 fix(relaykit): preserve tool argument numbers in Claude responses (QuantumNous#7996)
- f1569d1 fix(pricing): classify dynamic per-request billing correctly (QuantumNous#8010)
- bc795cc fix:修复stop为非字符串和[]string的协议转换问题 (QuantumNous#7935)
- 9823ebc fix(billing): bill cache_creation_input_tokens reported in prompt_tokens_details (QuantumNous#7909)
- e835b1b chore(deps): bump axios from 1.18.1 to 1.20.0 in /web (QuantumNous#7835)
- 5c8032d chore(deps): bump react-i18next from 17.0.10 to 17.1.0 in /web (QuantumNous#7981)
- 0b667ca chore(deps): bump i18next from 26.3.6 to 26.5.3 in /web (QuantumNous#7979)
- 4105bd0 chore(deps): bump input-otp from 1.4.2 to 1.5.0 in /web (QuantumNous#7980)
- b6b85ca chore(deps): bump react-resizable-panels from 4.12.2 to 4.14.6 in /web (QuantumNous#7982)
- 1dafb19 fix(gemini): preserve top-level imageConfig in chat conversion
- 0034b24 fix(task): wait up to 72 hours before timing out tasks
- a404460 chore(web): upgrade Bun to 1.4.4 and use bun check
- 33c61a2 fix: prevent stale values when switching edit drawer records (QuantumNous#7989)
- 30748c6 fix(logging): 隐藏访问日志中的查询凭据 (QuantumNous#7972)
- 7fb6e57 fix(channels): preserve advanced custom body passthrough settings (QuantumNous#7971)
- e9d4d63 feat(billing): bill OpenAI 12-hour prompt cache writes at their own price (QuantumNous#7965)
- d0b840e fix(relay): keep the client's JSON Schema property order
- d8e6561 feat(web): copy model names from usage log details
- 8802113 feat(task): let ordinary channels compete on shared plugin endpoints
- eb169e7 feat(pricing): adjust synced upstream prices by the site exchange rate
- e2321a5 chore(web): sort locale keys
- db80ac8 fix(task): let task plugins validate their own requests
- dbe97be feat(task): pass client request headers to task plugin drivers
- 556517f feat(task): accept multipart bodies on native plugin routes
- 94cc3ff fix(billing): bill Claude cache writes that arrive without a 5m/1h split
- 7e65967 fix(relay): stop cutting off slow clients during large stream events
- 0c2af97 fix(relay): finish delivered Responses streams without false disconnect errors (QuantumNous#7956)
- 7d8b912 fix: upgrade Go to 1.26.10 for CVE-2026-111943 (QuantumNous#7942)
- 4d36f2c chore(deps-dev): bump vitest from 4.1.10 to 5.0.4 in /web (QuantumNous#7838)
- eea05e0 chore(deps): bump github.com/klauspost/compress from 1.18.3 to 1.18.7 (QuantumNous#7931)

Local tests not run (CI-only).
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.

Azure channels (type 3) cannot serve /v1/responses WebSocket and are excluded by FilterResponsesWebSocket

1 participant