feat: support streaming for audio with raw audio chunk forwarding - #2603
feat: support streaming for audio with raw audio chunk forwarding#2603tovarsh wants to merge 4949 commits into
Conversation
fix: cast size to int64 before comparing with MaxUint32
fix: root page does not have analytic code
feat: add claude-opus-4-5-20251101
…ini-integration-011nJGemhrPUdqwg3qDvmqVB feat: enable thoughtSignature for non-function-call messages
fix: volcengine && baidu claude adapter
fix: volcengine claude DoResponse
fix: volcengine claude DoResponse
…pro-image-preview-oai OAI生图接口支持gemini 3 pro image preview
…ageConfig fix: gemini image correct generationConfig
…ith i18n - Add SSEViewer component for interactive SSE message inspection * Display SSE data stream with collapsible panels * Show parsed JSON with syntax highlighting * Display key information badges (content, tokens, finish reason) * Support copy individual or all SSE messages * Show error messages with detailed information - Support Ctrl+V to paste images in chat input * Enable image paste in CustomInputRender component * Auto-detect and add pasted images to image list * Show toast notifications for paste results - Add complete i18n support for 6 languages * Chinese (zh): Complete translations * English (en): Complete translations * Japanese (ja): Add 28 new translations * French (fr): Add 28 new translations * Russian (ru): Add 28 new translations * Vietnamese (vi): Add 32 new translations - Update .gitignore to exclude data directory
…-i2v Gemini Veo3.1[AI Studio]增加图生视频支持
Ensure image file is closed using defer after opening.
…edit Gemini Image系列支持图像编辑
…d-oai feat: 视频下载和界面预览统一使用OAI标准接口
…ffaec308ac9c1cf2afa2de98c3d
* feat: add support for Doubao /v1/responses
…curity-check feat: check-in feature integrates Turnstile security check
fix: gemini request -> openai tool call
…QuantumNous#2556) * fix: fix model deployment style issues, lint problems, and i18n gaps. * fix: adjust the key not to be displayed on the frontend, tested via the backend. * fix: adjust the sidebar configuration logic to use the default configuration items if they are not defined.
…rride_trim_prefix
fix: 修复 gemini 文件类型不支持 image/jpg
…figuration && the AWS calling side did not apply the relay timeout.
fix: fix the proxyURL is empty, not using the default HTTP client configuration && the AWS calling side did not apply the relay timeout.
fix: add tips for model management and channel testing
问题描述: - 使用 auto 分组的令牌调用 /v1/videos 等 Task 接口时,虽然任务能成功创建, 但使用日志不显示记录,且不会扣费 根本原因: - Distribute 中间件在选择渠道后,会将实际选中的分组存储在 ContextKeyAutoGroup 中 - 但 RelayTaskSubmit 函数没有从 context 中读取这个值来更新 info.UsingGroup - 导致 info.UsingGroup 始终是 "auto" 而不是实际选中的分组(如 "sora2逆") - 当 auto 分组的倍率配置为 0 时,quota 计算结果为 0 - 日志记录条件 "if quota != 0" 不满足,导致日志不记录、不扣费 修复方案: - 在 RelayTaskSubmit 函数中计算分组倍率之前,添加从 ContextKeyAutoGroup 获取实际分组的逻辑 - 使用安全的类型断言,避免潜在的 panic 风险 影响范围: - 仅影响 Task Relay 流程(/v1/videos, /suno, /kling 等接口) - 不影响使用具体分组令牌的调用 - 不影响其他 Relay 类型(chat/completions 等已有类似处理逻辑)
…task-logging fix(task): 修复使用 auto 分组时 Task Relay 不记录日志和不扣费的问题
fix: 设置默认max req body 为128MB
WalkthroughThis PR introduces HTTP streaming support for audio requests by adding a Stream boolean field to AudioRequest in both the OpenAPI schema and DTO layer, updating streaming detection logic, and implementing streaming response handling in the audio handler with token-based quota consumption. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Handler as Audio Handler
participant Upstream as Upstream Service
participant Quota as Quota System
Client->>Handler: Audio Request (Stream=true)
Handler->>Handler: Validate request & check Stream flag
Handler->>Upstream: Forward audio request
Upstream-->>Handler: Response (audio/*, chunked)
Handler->>Handler: Setup streaming response
Handler->>Client: Forward headers (excluding Content-Length, etc.)
loop Stream audio chunks
Upstream-->>Handler: Chunk data
Handler->>Client: Write chunk
Handler->>Client: Flush (if supported)
end
Handler->>Handler: Token count input (utf8.RuneCountInString)
Handler->>Quota: Consume quota based on tokens
Quota-->>Handler: Quota updated
Handler->>Upstream: Close upstream body
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🔇 Additional comments (8)
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 |
|
Could you let me know why this was closed? Is there an alternative implementation being worked on? |
|
Sorry, we just did a force push, which caused your PR to be closed. |
|
lol, all right. |

PR说明
目前 new-api 的
/v1/audio/speech接口不支持流式返回。而根据 OpenAI 官方接口语义,audio/speech 支持在生成过程中以 HTTP 分块传输(chunked transfer)的方式持续返回音频字节流,该行为并非 SSE(Server-Sent Events)。
本 PR 在不破坏现有行为的前提下,为
/v1/audio/speech增加了符合 OpenAI 语义的音频流式支持。变更内容
1. 对齐 OpenAI 的 streaming 请求语义
在
AudioRequest中新增字段:并调整流式判断逻辑:
说明:
stream: true:用于对齐 OpenAI 官方 audio/speech 接口语义stream_format == "sse":保留现有 new-api 的历史行为2. Relay 层实现音频流直通转发
当满足以下两个条件时:
Content-Type以audio/开头stream=true或stream_format=sse)Relay 将:
DoResponse解析逻辑io.Copy将上游返回的音频字节流写入客户端响应该实现严格遵循 audio/speech 的协议语义,未引入 SSE。
3. 完整、无损的响应 Header 转发
为避免多值 Header 丢失(如
Set-Cookie等),响应头转发采用逐值Add的方式,并排除 hop-by-hop headers:保证 Header 语义完整性。
4. 指标统计与配额处理
在首次 flush 时记录
FirstResponseTime,确保链路时延统计准确由于 audio/speech 流式响应不返回 usage 信息:
postConsumeQuota路径记录消耗不引入新的计费模型,避免行为不确定性
设计说明
text/event-stream,因此不应使用 SSE兼容性说明
/v1/audio/speech行为完全不变stream_format == "sse"的调用方不受影响Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.