I use TTMSMCPCloudAIService component with Claude API to extract data from an invoice file.
When I try to upload a png image to Claude API, I get the following error
{"type":"error","error":{"type":"invalid_request_error","message":"messages.0.content.1.image.source.base64: The image was specified using the image/jpeg media type, but the image appears to be a image/png image"},"request_id":"req_011CZv4wpU8GBYp4eb8CMz3Z"}.
I have successfully uploaded other file types to Claude API, like jpg and pdf, without problems.
The method TTMSMCPCloudAI.BuildPostData, in unit TMS.MCP.CloudAI, has the following code
...
AUserContentParts := AUserContentParts + ',{"type":"image","source":{"type":"base64","media_type":"image/jpeg","data":"'+FFiles[i].GetData+'"}}';
...
This code uses "image/jpeg" without checking the actual image type of the file.
If I change that line to "image/png", the file is successfully uploaded.
So it seems there is a bug in this method. I don't know if there are other methods that can also have this issue.
Thanks in advance