ai icon indicating copy to clipboard operation
ai copied to clipboard

Support image editing (openai/luma)

Open bmichotte opened this issue 8 months ago • 1 comments

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

bmichotte avatar Apr 24 '25 07:04 bmichotte

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 avatar Apr 24 '25 23:04 shaper

@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 avatar Apr 27 '25 09:04 wong2

@wong2 this will not be implemented in the next 2 weeks

lgrammel avatar Apr 28 '25 15:04 lgrammel

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,
  },
});

gr2m avatar Dec 22 '25 18:12 gr2m