Skip to content

Inline images sent as raw base64 instead of data URI #137

@Jameswlepage

Description

@Jameswlepage

Summary

In AbstractOpenAiCompatibleTextGenerationModel, inline images are sent using $file->getBase64Data() which returns raw base64. The OpenAI API's image_url.url field expects a data URI (data:image/png;base64,...).

Fix

Use $file->getDataUri() instead of $file->getBase64Data() when building the image_url payload.

Error

Bad Request (400) - Failed to download image from iVBORw0KGgoAAAANSUhEUg...
Image URL is invalid.

The API interprets raw base64 as a URL and tries to download it.

Note

getBase64Data() is correct for the audio input API which expects raw base64 with a separate format field. It's only wrong for images where the URL field needs the full data URI.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions