diff --git a/.changeset/olive-teachers-grin.md b/.changeset/olive-teachers-grin.md new file mode 100644 index 000000000000..6552c710e8f7 --- /dev/null +++ b/.changeset/olive-teachers-grin.md @@ -0,0 +1,5 @@ +--- +'@ai-sdk/deepinfra': patch +--- + +feat(deepinfra): export DeepInfraImageModelOptions diff --git a/examples/ai-functions/src/deepinfra-image-options-types.test-d.ts b/examples/ai-functions/src/deepinfra-image-options-types.test-d.ts new file mode 100644 index 000000000000..febe9603ee6b --- /dev/null +++ b/examples/ai-functions/src/deepinfra-image-options-types.test-d.ts @@ -0,0 +1,14 @@ +import type { DeepInfraImageModelOptions } from '@ai-sdk/deepinfra'; +import { describe, expectTypeOf, it } from 'vitest'; + +describe('@ai-sdk/deepinfra', () => { + it('exports DeepInfraImageModelOptions for `providerOptions.deepinfra`', () => { + const options = { + guidance_scale: 7.5, + num_inference_steps: 25, + negative_prompt: 'blurry, distorted', + } satisfies DeepInfraImageModelOptions; + + expectTypeOf(options).toMatchTypeOf(); + }); +}); diff --git a/packages/deepinfra/src/deepinfra-image-settings.ts b/packages/deepinfra/src/deepinfra-image-settings.ts index eef652e2dab2..4a3e4255ca92 100644 --- a/packages/deepinfra/src/deepinfra-image-settings.ts +++ b/packages/deepinfra/src/deepinfra-image-settings.ts @@ -1,3 +1,5 @@ +import { z } from 'zod/v4'; + // https://deepinfra.com/models/text-to-image export type DeepInfraImageModelId = | 'stabilityai/sd3.5' @@ -10,3 +12,57 @@ export type DeepInfraImageModelId = | 'stabilityai/sd3.5-medium' | 'stabilityai/sdxl-turbo' | (string & {}); + +/** + * Provider-specific image model options for DeepInfra. + * + * These options are passed through the `providerOptions.deepinfra` parameter + * when calling image generation functions. Available parameters vary by model; + * the schema uses `.passthrough()` to allow any additional model-specific fields. + */ +export const deepInfraImageModelOptions = z + .object({ + /** + * Classifier-free guidance scale. + * + * Higher values mean the image follows the prompt more closely. + * Supported by FLUX-1-dev, FLUX-1-schnell, and Stable Diffusion models. + */ + guidance_scale: z.number().optional(), + + /** + * Number of denoising steps for the image generation process. + * + * More steps generally produce higher quality images but take longer. + * Supported by FLUX-1-dev, FLUX-1-schnell, and Stable Diffusion models. + */ + num_inference_steps: z.number().int().optional(), + + /** + * Negative prompt describing what to avoid in the generated image. + * + * Supported by Stable Diffusion models. + */ + negative_prompt: z.string().optional(), + + /** + * Whether to perform upsampling on the prompt. + * + * If active, automatically modifies the prompt for more creative generation. + * Supported by FLUX-1.1-pro and FLUX-pro models. + */ + prompt_upsampling: z.boolean().optional(), + + /** + * Tolerance level for input and output moderation. + * + * Between 0 and 6, 0 being most strict, 6 being least strict. + * Supported by FLUX-1.1-pro and FLUX-pro models. + */ + safety_tolerance: z.number().int().min(0).max(6).optional(), + }) + .passthrough(); + +export type DeepInfraImageModelOptions = z.infer< + typeof deepInfraImageModelOptions +>; diff --git a/packages/deepinfra/src/index.ts b/packages/deepinfra/src/index.ts index c10ddcf0618d..643b016abc7d 100644 --- a/packages/deepinfra/src/index.ts +++ b/packages/deepinfra/src/index.ts @@ -3,5 +3,6 @@ export type { DeepInfraProvider, DeepInfraProviderSettings, } from './deepinfra-provider'; +export type { DeepInfraImageModelOptions } from './deepinfra-image-settings'; export type { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible'; export { VERSION } from './version';