Support image editing (openai/luma)
Description
OpenAI has an "edit" image which allows to send multiple images to either refine, change, improve your image. https://platform.openai.com/docs/api-reference/images/createEdit https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1#edit-images
Luma also has this ability https://docs.lumalabs.ai/docs/image-generation#character-reference
It would be nice to have such options in the generateImage function
In the interim you can do this with Luma today, see the "Advanced Options" here: https://sdk.vercel.ai/providers/ai-sdk-providers/luma#character-reference
It is a little bit of a fortuitous accident that it works, in that their API to vary these behaviors happens to work within the surrounding generateImage internals.
I understand your request is more about adding a top level concept of editing an image, which we do want to do at some point. Thank you for the feature request!
@shaper Can we assume that the AI SDK won't add this feature in the short term (like in two weeks)? This way, we can decide whether to implement it ourselves first.
@wong2 this will not be implemented in the next 2 weeks
done now, for all 1st-class providers. See Black Forest Labs docs for example: https://ai-sdk.dev/providers/ai-sdk-providers/black-forest-labs#image-editing
import {
blackForestLabs,
BlackForestLabsImageProviderOptions,
} from '@ai-sdk/black-forest-labs';
import { generateImage } from 'ai';
const { images } = await generateImage({
model: blackForestLabs.image('flux-kontext-pro'),
prompt: {
text: 'A baby elephant with a shirt that has the logo from the input image.',
images: [
'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',
],
},
providerOptions: {
blackForestLabs: {
width: 1024,
height: 768,
} satisfies BlackForestLabsImageProviderOptions,
},
});