Skip to content

feat(provider): add image model options type definitions#12473

Closed
saakshigupta2002 wants to merge 3 commits intovercel:mainfrom
saakshigupta2002:fix/image-model-type-definitions
Closed

feat(provider): add image model options type definitions#12473
saakshigupta2002 wants to merge 3 commits intovercel:mainfrom
saakshigupta2002:fix/image-model-type-definitions

Conversation

@saakshigupta2002
Copy link

Summary

This PR adds TypeScript type definition interfaces for image model provider options across four providers: OpenAI, Amazon Bedrock, Fireworks, and Deepinfra. These interfaces provide type safety and IDE autocomplete support when using the providerOptions parameter for image generation, significantly improving the developer experience.

Currently, the image model provider options are passed as untyped objects via providerOptions.<provider>, which means developers get no compile-time validation or IDE assistance when configuring provider-specific image generation parameters. This PR addresses that gap by defining and exporting typed interfaces for each provider.

Changes

OpenAI Provider (@ai-sdk/openai)

Added OpenAIImageModelOptions interface with properties: quality, style, background, output_format, output_compression, input_fidelity, partial_images, user

Export: Added to packages/openai/src/index.ts

Amazon Bedrock Provider (@ai-sdk/amazon-bedrock)

Added AmazonBedrockImageModelOptions interface with properties: quality, cfgScale, negativeText, style, taskType, maskPrompt, outPaintingMode, similarityStrength

Export: Added to packages/amazon-bedrock/src/index.ts

Fireworks Provider (@ai-sdk/fireworks)

Added FireworksImageModelOptions interface with properties: guidance_scale, num_inference_steps, negative_prompt, strength, scheduler, safety_checker

Export: Added to packages/fireworks/src/index.ts

Deepinfra Provider (@ai-sdk/deepinfra)

Added DeepinfraImageModelOptions interface with properties: guidance_scale, num_inference_steps, negative_prompt, strength, scheduler, image_format, response_format

Export: Added to packages/deepinfra/src/index.ts

Design Decisions

  1. Interface properties derived from actual usage: Each interface's properties were identified by analyzing the existing providerOptions.<provider> access patterns in each provider's image model implementation, ensuring full coverage of supported options.

  2. Comprehensive JSDoc documentation: All properties include detailed JSDoc comments with descriptions, valid value ranges, default values, and usage examples to maximize IDE tooltip usefulness.

  3. Consistent naming conventions: Interface names follow the established SDK pattern: {Provider}{Feature}Options (e.g., OpenAIImageModelOptions, matching OpenAILanguageModelChatOptions).

  4. All properties optional: Every property is optional to maintain backward compatibility — existing code that passes partial or no provider options continues to work without changes.

Verification

  • TypeScript compilation: pnpm turbo build passes successfully for all four packages and their dependencies (9 tasks, 0 failures)
  • Linting: pnpm turbo lint passes successfully for all four packages (9 tasks, 0 failures)
  • No breaking changes: All additions are purely additive type exports — no runtime behavior changes

Related Issues

Closes #12437
Closes #12435
Closes #12439
Closes #12460

Add TypeScript interfaces for image model provider options across
four providers to improve type safety and developer experience:

- OpenAIImageModelOptions: quality, style, background, output_format,
  output_compression, input_fidelity, partial_images, user
- AmazonBedrockImageModelOptions: quality, cfgScale, negativeText,
  style, taskType, maskPrompt, outPaintingMode, similarityStrength
- FireworksImageModelOptions: guidance_scale, num_inference_steps,
  negative_prompt, strength, scheduler, safety_checker
- DeepinfraImageModelOptions: guidance_scale, num_inference_steps,
  negative_prompt, strength, scheduler, image_format, response_format

All interfaces are exported from their respective package entry points
and include comprehensive JSDoc documentation.

Fixes vercel#12437, vercel#12435, vercel#12439, vercel#12460
*
* @see https://deepinfra.com/models/text-to-image
*/
export interface DeepinfraImageModelOptions {
Copy link
Contributor

@vercel vercel bot Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeepinfraImageModelOptions uses inconsistent casing (Deepinfra with lowercase 'i') while all other exported types in the package use DeepInfra (capital 'I').

Fix on Vercel

Comment on lines +71 to +77
* Determines how the image should be extended.
*
* - `DEFAULT`: Standard outpainting
* - `PRECISE`: More precise adherence to original image style
* - `CREATIVE`: More creative freedom in extended areas
*/
outPaintingMode?: 'DEFAULT' | 'PRECISE' | 'CREATIVE';
Copy link
Contributor

@vercel vercel bot Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outPaintingMode type union includes 'CREATIVE' which is not a valid AWS Bedrock API value, misleading users into using an unsupported option that will cause API errors.

Fix on Vercel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is indeed the case, looking at the "Outpainting request" docs in https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html. Needs to be fixed in the schema.

Copy link
Contributor

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saakshigupta2002 Thank you for opening a PR for these issues!

Note that introducing the types alone is not sufficient, they also need to be used in their respective provider packages, and in the examples in examples/ai-functions that use those providers.

I left some more notes below; because of this being more work and requiring careful review of each provider's specific image generation parameters and how they're passed, I would suggest you open individual pull requests for each issue. This way we can work through each provider one by one - it'll simplify things and also mean we don't have to hold up all providers in case one of them is more complex to get right.

*
* @see https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html
*/
export interface AmazonBedrockImageModelOptions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to declaring the type for each provider, we also need to parse the given providerOptions for an image generation call against it, via the parseProviderOptions helper.

The recommended approach used elsewhere for this is to define this as a Zod schema instead and infer the type. Take a look at for example packages/xai/src/xai-image-options.ts and packages/xai/src/xai-image-model.ts.

This feedback applies to all providers in the PR.

Comment on lines +71 to +77
* Determines how the image should be extended.
*
* - `DEFAULT`: Standard outpainting
* - `PRECISE`: More precise adherence to original image style
* - `CREATIVE`: More creative freedom in extended areas
*/
outPaintingMode?: 'DEFAULT' | 'PRECISE' | 'CREATIVE';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is indeed the case, looking at the "Outpainting request" docs in https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html. Needs to be fixed in the schema.

@saakshigupta2002
Copy link
Author

Thank you for the detailed review @felixarntz! You're absolutely right — I'll rework this with Zod schemas and parseProviderOptions integration as shown in the xAI reference implementation. I'll re-submit as individual PRs per provider to keep things manageable.

@saakshigupta2002 saakshigupta2002 deleted the fix/image-model-type-definitions branch February 13, 2026 07:03
@saakshigupta2002
Copy link
Author

@saakshigupta2002 Thank you for opening a PR for these issues!

Note that introducing the types alone is not sufficient, they also need to be used in their respective provider packages, and in the examples in examples/ai-functions that use those providers.

I left some more notes below; because of this being more work and requiring careful review of each provider's specific image generation parameters and how they're passed, I would suggest you open individual pull requests for each issue. This way we can work through each provider one by one - it'll simplify things and also mean we don't have to hold up all providers in case one of them is more complex to get right.

Thanks for the review! I've reworked my previous approach based on your feedback - which split into separate PRs as per provider, added Zod schemas with parseProviderOptions, updated the examples with satisfies and included changesets. Here are the new PRs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants