Fix server API key fallback when client echoes provider base URL#533
Open
LooThao wants to merge 2 commits into
Open
Fix server API key fallback when client echoes provider base URL#533LooThao wants to merge 2 commits into
LooThao wants to merge 2 commits into
Conversation
45ef52a to
209a9ab
Compare
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.
Summary
Fix server-configured providers losing their API key when the client sends back the same server-provided base URL.
This expands the original TTS fix to the shared provider resolution path and the media/document routes that use server-side provider credentials.
Problem
Several API routes treated any request containing a Base URL as a fully client-configured provider. The settings UI can echo a server-configured Base URL back to these routes while leaving the client API key empty. In that case server-configured providers fail with missing API key errors even though the key exists on the server.
Examples include MiniMax TTS/LLM, image generation, video generation, transcription, and PDF provider routes.
Fix
Add a shared
canUseServerApiKeyForBaseUrlguard and use it across provider routes:Covered routes:
/api/generate/tts/api/generate/image/api/generate/video/api/verify-image-provider/api/verify-video-provider/api/transcription/api/parse-pdf/api/verify-pdf-providerresolveModelTest
pnpm exec eslint app/api/generate/image/route.ts app/api/generate/video/route.ts app/api/verify-image-provider/route.ts app/api/verify-video-provider/route.ts app/api/transcription/route.ts app/api/parse-pdf/route.ts app/api/verify-pdf-provider/route.ts app/api/generate/tts/route.ts lib/server/resolve-model.ts lib/server/provider-config.tsAlso verified locally that server-configured MiniMax TTS succeeds when the client leaves the API key empty and echoes the server Base URL.