
azure-openai
#10048
input_validation_error
Invalid image URL: The URL must be a valid HTTP, HTTPS, or a base64-encoded data URL.
This error has been identified and solved.
Reason
The 400 status error in the Azure OpenAI API, specifically related to an "Invalid image URL," can be caused by several factors:
Invalid URL Encoding
The image URL may contain encoded characters that are not properly handled. For example, URLs from storage services like Firebase can include encoded characters (e.g., %2F
instead of /
) which can make the URL invalid when processed by the API.
Incorrect URL Format
The URL provided might not be a valid HTTP or HTTPS URL, or it may not be a correct data URL with base64 encoding. The API expects a specific format, and any deviation from this can result in a 400 error.
Private Blob Access Issues
If the image is stored in a private Azure Blob, the URL might not include the necessary permissions or SAS (Shared Access Signature) token, leading to an invalid URL error when the API tries to access the image.
Malformed or Incomplete URL
The URL could be malformed or incomplete, lacking necessary components such as the protocol (http/https), the domain, or other required parameters, which would make it invalid for the API to process.
Solution
To resolve the "Invalid image URL" error in the Azure OpenAI API, you need to ensure the following:
Verify that the URL is a valid HTTP or HTTPS URL.
If using base64 encoding, ensure it is properly formatted as a data URL.
For images stored in Azure Blob, include the necessary SAS (Shared Access Signature) token in the URL.
Check that the URL does not contain malformed or encoded characters that could make it invalid.
Key steps to take:
Ensure the URL includes the correct protocol (http/https) and domain.
Use a valid data URL format if base64 encoding is used.
Include the necessary permissions or SAS token for private blob access.
Double-check the URL for any malformations or missing components.
Suggested Links
https://cheatsheet.md/chatgpt-cheatsheet/openai-api-error-axioserror-request-failed-status-code-400
https://learn.microsoft.com/fi-fi/azure/ai-services/openai/reference
https://community.openai.com/t/gpt-4-vision-error-badrequesterror-400-invalid-image/516486
https://learn.microsoft.com/en-us/answers/questions/2139738/openai-badrequesterror-error-code-400-((error-((me
https://learn.microsoft.com/en-us/answers/questions/2108677/how-can-i-allow-azure-openai-to-access-a-private-b
https://community.openai.com/t/gpt-4o-sometime-not-able-to-access-image-from-url/903528
https://community.openai.com/t/how-to-send-base64-images-to-assistant-api/752440
https://community.openai.com/t/error-sending-base64-image-data-in-api-request-to-gpt-4-vision-model/495864
https://portkey.ai/error-library/unsupported-image-error-10015