
anthropic
#10498
input_validation_error
The input for 'messages.0.content.2.image.source.media_type' is invalid. Acceptable media types are 'image/jpeg', 'image/png', 'image/gif', or 'image/webp'.
This error has been identified and solved.
Reason
The 400 status error you are encountering, specifically the message messages.0.content.2.image.source.media_type: Input should be 'image/jpeg', 'image/png', 'image/gif' or 'image/webp'
, indicates that the media type of the image you are trying to send does not match one of the accepted formats. The Anthropic API only accepts images in the formats image/jpeg
, image/png
, image/gif
, or image/webp
, and your current image does not comply with these requirements.
Solution
To fix the 400 status error, you need to ensure that the image you are sending is in one of the supported formats. Here are the steps to resolve the issue:
Ensure the image is in one of the following formats:
image/jpeg
image/png
image/gif
image/webp
Check and correct the media_type
field in your API request to match the actual format of the image.
Verify that the image is properly encoded in base64 and included in the request as specified by the API documentation.
Suggested Links
https://github.com/continuedev/continue/issues/2006
https://community.openai.com/t/400-error-when-i-include-base64-image-in-a-prompt/788596
https://docs.anthropic.com/en/api/errors
https://github.com/BerriAI/litellm/issues/6893
https://community.openai.com/t/request-failed-with-status-code-400/39242/25
https://docs.anthropic.com/en/api/messages
https://community.openai.com/t/400-error-on-gpt-vision-emerges-out-of-nowhere-solved/606227
https://www.acorn.io/resources/learning-center/claude-api/
https://community.openai.com/t/400-errors-on-gpt-vision-api-since-today/534538
https://www.restack.io/p/anthropic-answer-image-api-cat-ai