Why do some responses message content start with ```json?

Hi,

I am using the api.openai.com/v1/chat/completions API and it is working great. Occasionally the response’s content key will contain a value that starts with ```json and ends with ```.

Does anyone know why and how to prevent it from happening?

Thanks,
John

Hi and welcome to the Developer Forum!

It’s an artefact from the json mode training, the best thing to do is to strip ```json ``` from your output via regex.

See:

2 Likes