Repository navigation
fix: OpenRouter 转写专用模型改走 /audio/transcriptions - #127
Open
sheepbox8646 wants to merge 1 commit into
Open
sheepbox8646 wants to merge 1 commit into
sheepbox8646 wants to merge 1 commit into
Conversation
OpenRouter 转写 provider 原来把所有模型都发到 /chat/completions,默认模型 openai/gpt-4o-mini-transcribe 因此必定返回 400。现在按 OpenRouter 模型目录判断:输出只有 transcription 的模型走 /audio/transcriptions(multipart),其他带音频输入的对话模型仍走 /chat/completions。目录按 Provider 缓存一小时,拉取失败时回退到按模型 ID 判断。 Linear: TWI-14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
provider/openrouter/transcription把所有模型都按input_audio发到/chat/completions。默认模型openai/gpt-4o-mini-transcribe是转写专用模型,OpenRouter 会拒绝:所以
TranscriptionModel("")必定失败。output_modalities含transcription且不含text的模型,走/audio/transcriptions(multipart)。其他带音频输入的对话模型(如openai/gpt-audio-mini、qwen/qwen3.8-omni-flash)仍走/chat/completions,行为不变。/models?output_modalities=all,每个 Provider 缓存一小时。ListModels的结果也会写入缓存。:variant后缀。scribe或whisper,或某个名称片段正好是asr、stt。model、file,以及可选的language、temperature、response_format、timestamp_granularities[]、keyterms、diarize。文件名缺扩展名时,按 content type 补上。prompt只用于对话模型:转写端点文档里没有这个字段,所以不发送。text、language、duration直接映射,没有duration时用usage.seconds。words映射到Words,说话人填入SpeakerID。openai/gpt-4o-mini-transcribe现在会走正确的端点。docs/speech.md新增 OpenRouter 转写一节,说明端点选择、各配置项适用的端点和结果映射。关联
验证
:free变体、目录结果优先于名称判断。ListModels的结果会被复用。Content-Disposition。APIError。go build ./...、go vet ./...、go vet -tags integration ./...、go test ./... -short -count=1 -race、golangci-lint run ./...,全部通过。go mod tidy无变化。openai/whisper-large-v3-turbothe quick brown fox jumps over the lazy dog.mistralai/voxtral-mini-3b-2507elevenlabs/scribe-v2qwen/qwen3.8-omni-flashopenai/gpt-4o-mini-transcribe)openai/gpt-audio-minimime.FormatMediaType生成的Content-Disposition参数没加引号、顺序也被重排,OpenRouter 会返回400 Invalid multipart/form-data body。现在改成与标准库CreateFormFile一致的写法,并加了回归测试。未验证
verbose_json时,它返回does not support response_format "verbose_json",这个报错只会来自/audio/transcriptions。keyterms、diarize只做了单元测试。ListModels只要求输入含 audio,所以会把heygen/*等视频生成模型也列为可转写模型。🤖 Generated with Claude Code