fix(openai-compatible): honor camelCase providerOptions key in chat and completion models#14135
Open
seojcarlos wants to merge 1 commit intovercel:mainfrom
Open
Conversation
…nd completion models The docs state that providerOptions keys are camelCased (e.g. provider-name -> providerName), but chat and completion models only looked up the raw provider name. The image model already had the correct fallback behavior. This extracts the toCamelCase helper into a shared module and adds the camelCase key fallback to both chat and completion models, matching the existing image model pattern. Fixes vercel#14105
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
Fixes #14105
The docs state that
providerOptionskeys should use camelCase (e.g.provider-name→providerName), but chat and completion models only looked up the raw provider name. The image model already had the correct fallback behavior.Root Cause
When using
createOpenAICompatible({ name: 'provider-name' }), the image model merges both raw and camelCase keys:But chat and completion models only checked the raw key:
This means
providerOptions.providerNamewas ignored in chat/completion while working in image.Fix
toCamelCaseinto a shared module (to-camel-case.ts) used by all three modelsparseProviderOptions+ direct spread)toCamelCasefrom image model (now uses shared import)The camelCase key takes precedence over the raw key (via
Object.assignordering), matching the documented behavior.Changed Files
packages/openai-compatible/src/to-camel-case.ts— new shared utilitypackages/openai-compatible/src/chat/openai-compatible-chat-language-model.ts— add camelCase fallbackpackages/openai-compatible/src/completion/openai-compatible-completion-language-model.ts— add camelCase fallbackpackages/openai-compatible/src/image/openai-compatible-image-model.ts— use shared import