OpenAI API Issues - JSON formatting

I have a very weird issue I am stuck on with OpenAI API.

I am sending prompt to OpenAI API

  • If I pass “gpt-4” as a model , it works all the times
  • If I pass “gpt-3.5-turbo-16k” as model and the same prompt it fails all the times (“What was sent was not a valid JSON”) - nothing else changes … Analysing the prompt sent in the logs I can’t find any problematic syntax or character

I am confused:

  • Does open AI reacts differently to the format sent based on the model ?
  • Is there anything better than :formatted as JSON that would work in all cases ?

What am I missing ?

Bellow works fine, all the time

Bellow given me the not valid JSON error