Skip to content

Image generation with OpenAI doesn't work if Guidelines are used #496

@dkotter

Description

@dkotter

Description

In #359 we added support for the new Guidelines experiment in Gutenberg. This allows you set various guidelines (site, copy, image, block) that others can then use as reference. In our case, we take those guidelines and attach them to our system instructions for various features.

In testing something else, ran into an issue where image generation would return the error Image generation failed. Please ensure you have a connected provider that supports image generation. In tracking down what was going on, found out that OpenAI doesn't support system instructions for their image models and so if you have either site or image guidelines set, those get added as system instructions and then the AI Client can't find any models that support image generation, leading to the mentioned error.

It seems some of the Google models also don't support instructions (any of the imagen ones) but the gemini models do. Likely other image models from other providers will also have various degrees of support.

I think there's a few options we can look to take here:

  1. Remove the use of guidelines entirely from image generation
  2. Instead of setting these as system instructions, add them as part of the prompt. This preserves the guidelines and should work for any image generation model. This probably makes more sense anyway when dealing with image generation (which was my mistake as I recommended this approach to match what we do elsewhere)
  3. Keep these as system instructions for models that support it and remove when the model doesn't. This is tricky to do as we don't know the model until the AI Client tries to make the request

Step-by-step reproduction instructions

  1. Install Gutenberg and enable the Guidelines experiment
  2. Add a Site guideline and Images guideline
  3. Setup OpenAI as your AI Connector
  4. Turn on image generation
  5. Try and generate an image. You should see an error

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except the AI plugin.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Type] BugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions