feat(openai): add OpenAIImageModelOptions type with providerOptions validation#12555
Open
saakshigupta2002 wants to merge 1 commit intovercel:mainfrom
Open
feat(openai): add OpenAIImageModelOptions type with providerOptions validation#12555saakshigupta2002 wants to merge 1 commit intovercel:mainfrom
saakshigupta2002 wants to merge 1 commit intovercel:mainfrom
Conversation
…alidation Define a Zod schema for OpenAI image generation provider options and integrate it with parseProviderOptions for runtime validation. Export the inferred OpenAIImageModelOptions type for consumer use. - Add openaiImageModelOptions Zod schema in openai-image-options.ts - Replace raw providerOptions spread with parseProviderOptions call - Use individual property assignments for type-safe option passing - Export OpenAIImageModelOptions from package entry point - Update openai-gpt-image example to use satisfies with the new type - Add changeset for patch release Fixes vercel#12437
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
Adds a proper
OpenAIImageModelOptionstype definition for OpenAI image model provider options, backed by a Zod schema and validated at runtime usingparseProviderOptions.This addresses the lack of type safety for OpenAI image generation provider options. Previously, users had no TypeScript guidance when passing
providerOptions.openaifor image models.Changes
packages/openai/src/image/openai-image-options.ts: Added Zod schema (openaiImageModelOptions) defining all supported OpenAI image generation options (quality,style,background,output_format,output_compression,input_fidelity,partial_images,user). Exported inferredOpenAIImageModelOptionstype.packages/openai/src/image/openai-image-model.ts: IntegratedparseProviderOptionsto validate provider options against the Zod schema at runtime, replacing unvalidated raw access. Provider options are now consumed via individual property assignments.packages/openai/src/index.ts: ExportedOpenAIImageModelOptionstype.examples/ai-functions/src/generate-image/openai-gpt-image.ts: Updated example to import and usesatisfies OpenAIImageModelOptionsfor type-safe provider options.Verification
pnpm turbo build --filter=@ai-sdk/openai)pnpm turbo lint --filter=@ai-sdk/openai)pnpm vitest packages/openai/src/image/ --run— 22/22)Closes #12437