Skip to content

Conversation

Copy link

Copilot AI commented Nov 27, 2025

Inline images were being sent as raw base64 to the OpenAI API, which expects a data URI (data:image/png;base64,...) for the image_url.url field. This caused 400 errors as the API attempted to download the base64 string as a URL.

Changes

  • Use $file->getDataUri() instead of $file->getBase64Data() for inline images in AbstractOpenAiCompatibleTextGenerationModel::getMessagePartContentData()
  • Update test expectation to match correct data URI format

Note: Audio inputs correctly continue using getBase64Data() since that API expects raw base64 with a separate format field.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/f7eb16f2fa4237d5db9e8fed8050239bee17a9bd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/6e10469b0f3827862b37df2ac2b7ec4580ce888f
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/clue/stream-filter/zipball/049509fef80032cb3f051595029ab75b49a3c2f7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/client-common/zipball/0cfe9858ab9d3b213041b947c881d5b19ceeca46
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/curl-client/zipball/f3eb48d266341afec0229a7a37a03521d3646b81
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/httplug/zipball/5cad731844891a4c282f3f3e1b582c46839d22f4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/message-factory/zipball/4d8778e1c7d405cbb471574821c1ff5b68cc8f57
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/message/zipball/06dd5e8562f84e641bf929bfe699ee0f5ce8080a
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/mock-client/zipball/81f558234421f7da58ed015604a03808996017d0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/php-http/promise/zipball/fc85b1fba37c169a69a07ef0d5a8075770cc1f83
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/phpstan/phpdoc-parser/zipball/b9e61a61e39e02dd90944e9115241c7f7e76bfd8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/41600c8379eb5aee63e9413fe9e97273e25d57e4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea49afa29aeea25ea7bf9de9fdd7cab163cc0701
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/slevomat/coding-standard/zipball/b4f9f02edd4e6a586777f0cabe8d05574323f3eb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/aF8zSF /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/symfony/options-resolver/zipball/74e5b6f0db3e8589e6cfd5efb317a1fc2bb52fb6
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/1ygweD /usr/bin/composer install --no-progress (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Inline images sent as raw base64 instead of data URI</issue_title>
<issue_description>## 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.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix inline images to use data URI for OpenAI API Fix inline images to use data URI format instead of raw base64 Nov 27, 2025
Copilot AI requested a review from Jameswlepage November 27, 2025 20:09
Copilot finished work on behalf of Jameswlepage November 27, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline images sent as raw base64 instead of data URI

2 participants