Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-teachers-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ai-sdk/deepinfra': patch
---

feat(deepinfra): export DeepInfraImageModelOptions
14 changes: 14 additions & 0 deletions examples/ai-functions/src/deepinfra-image-options-types.test-d.ts
Original file line number Diff line number Diff line change
@@ -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<DeepInfraImageModelOptions>();
});
});
56 changes: 56 additions & 0 deletions packages/deepinfra/src/deepinfra-image-settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { z } from 'zod/v4';

// https://deepinfra.com/models/text-to-image
export type DeepInfraImageModelId =
| 'stabilityai/sd3.5'
Expand All @@ -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
>;
1 change: 1 addition & 0 deletions packages/deepinfra/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Loading