Warning appears while using automators for image type field "Warning: Undefined array key "b64_json" in Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider->textToImage() "

Created on 6 February 2025, 3 months ago

Problem/Motivation

When i enabled image automator to generate image and selected "default Image to text model" the node save was triggering warnings and not able to generate and save the image in the field.

Warning: Undefined array key "b64_json" in Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider->textToImage() (line 404 of /var/www/html/docroot/modules/contrib/ai_provider_openai/src/Plugin/AiProvider/OpenAiProvider.php)

Steps to reproduce

  • Enable and configure the Openai module
  • add an image field to a content type and enable automator plugin
  • under Advanced >> AI Provider >> select "Default Text To Image model"
  • Save the node and the warning should appear

Response: Below is the payload being passed in case of default.

[
  "model" => "dall-e-3"
  "prompt" => "Add any random image."
]

Proposed resolution

passing a response_format should fix the issue of warning and generate an image.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India vakulrai

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024