Help with curl for GPT 4 Vision Macro (v11.0.1)
Hi there, would appreciate getting any advice on getting the OpenAI vision endpoint to work with curl in KM terminal. I'm guessing there's some sort of escaping I need to do since I'm encoding the image as base64 but I just haven't been able to figure out how or what the true issue is.
Here's a link to the OpenAI documentation for Uploading a base 64 encoded image.
Thanks ahead of time for the help!
GPT 4 Vision.kmmacros (4.1 KB)
Hi there, would appreciate getting any advice on getting the OpenAI vision endpoint to work with curl in KM terminal. I'm guessing there's some sort of escaping I need to do since I'm encoding the image as base64 but I just haven't been able to figure out how or what the true issue is.
Here's a link to the OpenAI documentation for Uploading a base 64 encoded image.
Thanks ahead of time for the help!
Not able to be much help because I can't test this but:
Rather than a KM variable for the base 64 data (which might exceed the KM environment space), I'd use the OpenAI function to write the data to a file and access the data in the file. You'd just have to pass it the KM variable path to the screenshot. And no escaping required.
Hey thanks for the response! Trying to make sure I understand your suggestion.
Are you saying for me to save the base 64 string as a file, then load the file in the shell script with the path?
Yes, that's what the OpenAI documentation does. And it makes sense for Keyboard Maestro because there are issues with large variables overruning its environmental space.
I'll give it a go again tomorrow and see what I can come up with. In the OpenAI docs it's still sending a base 64 string, so I guess what you're saying is that there would be a difference in converting the image to base 64 at the time of the bash script running, rather than storing it in a variable then inserting into the curl script.
Thanks for taking the time to answer.
The difference is that writing the base 64 data to a file does not have the memory restriction in environment space that trying to store it in a Keyboard Maestro variable.