Logo

azure-openai

#10043

input_format_error

Invalid image data: the provided image data is not correctly formatted in base64.

This error has been identified and solved.

Reason

The status error when sending base64 image data to the Azure OpenAI API can be caused by several reasons:

Invalid Image Format

The base64 encoded image may not be in the correct format or may be corrupted, leading to the API being unable to process it.

Incorrect Payload Structure

The API expects a specific structure for the request payload, particularly when dealing with images. For example, the content field should contain an array of content objects, and images should be specified with the correct type (e.g., image_url or image), but the documentation and actual implementation may have discrepancies.

API Endpoint and Model Compatibility

The API endpoint and the model used (e.g., gpt-4-vision-preview) may have specific requirements or limitations for handling base64 image data, which if not met, can result in a 400 error.

Invalid or Missing Headers

Incorrect or missing headers, such as the Authorization or Content-Type headers, can also trigger a 400 error because the request is not properly configured.

Rate Limiting or Throttling

While less likely for image data specifically, hitting rate limits or throttling constraints can also result in a 400 error, indicating that the request was not processed due to excessive usage.

Invalid Input

The API may reject the request if the input, including the base64 image data, does not conform to the expected format or contains invalid data, such as an empty string or malformed base64 encoding.

Solution

To fix the 400 status error when sending base64 image data to the Azure OpenAI API, you need to ensure the following:

  • Correct Base64 Encoding: Verify that the image data is correctly base64 encoded and not corrupted.

  • Proper Payload Structure: Ensure the request payload is structured correctly, with the content field containing an array of content objects and the image specified with the correct type (e.g., using image_url with a base64 encoded string like data:image/jpeg;base64,[base64 encoded image content]).

  • Compatible API Endpoint and Model: Use the correct API endpoint and model that supports base64 image data, such as gpt-4-vision-preview or GPT-4 Turbo with Vision.

  • Correct Headers: Make sure the Authorization and Content-Type headers are included and correctly configured.

  • Check Image Size and Format: Ensure the image is within the size limits (e.g., below 20 MB) and in a supported format (e.g., png, jpeg, gif, webp).

By addressing these points, you should be able to resolve the error and successfully send base64 image data to the Azure OpenAI API.

Original Error Message

Raw

Invalid image data: the provided image data is not correctly formatted in base64.

Original Error Message

Raw

Invalid image data: the provided image data is not correctly formatted in base64.

Suggested Links

© 2024 Portkey, Inc. All rights reserved

HIPAA

COMPLIANT

GDPR

Transform Your AI app prototypes to be production-ready

Talk to us →