I want to send pictures to the open AI vision API (https://platform.openai.com/docs/guides/vision ) to ask questions. The amount of pictures can vary. Therefore I wanted to handover the image party dynamically.
Initialization worked fine and I can trigger the API if I use the JSON code I used to create the API connection. I use the standard bubble API connector.
As you can see, I tried already various stuff like making it JSON safe and getting rid of the quotation marks since it does not fit to the openAI documentation. The prompt and the model work as expected.
In the arbitrary text I wrote different version of the JSON I wanted to have. Such as image URL retrieval from the database (my prefered way), storing the JSON in a custom state, storing and retrieving the URL and the JSON in the database and doing a search for.
It’s hard to know without the full request payload you are sending. We don’t see what you are doing in your arbitrary text and having a find and replace after format as json-safe sound a bad idea to me.
I don’t consider this is the correct way. You are adding more step that you don’t need. You already have the JSON created, you don’t need to encode it as json-safe. This is to be used for a string. Don’t forget that encoded as json-safe add surrounding double quotes to string. If the API expect a string, that’s fine, but now you are sending a text, not a JSON object. Also, if you use find and replace to remove the first " and last ", this won’t work because now, all the JSON was escaped.
Send the request you have actually to a requestbin.com for example and inspect the body sent. You will probably see all json error (you can use jsonlint to validate the body)