Can I send JSON as input instead of plain text?

Hi, I couldn’t find anything about this in the official docs. At the moment I’m sending input to GPT as plain text, but I’d like to know if it’s possible to send JSON objects directly. The goal would be to provide structured information (like time, date, or other fields) separately from the user’s text, instead of merging everything into one string.

Is this supported today, or should all inputs always be plain text unless I use tool/function calling with parameters?

Thanks!

1 Like

You could if you want to.

2 Likes

You can send the model any text, including JSON, XML or YAML, base-64 encodings, etc.

I typically use json when I am presenting the the model with a table of data. I find that it is less compact than other forms (markdown, YAML) but the model understands it better and can build smarter replies.

structure can also be useful for presenting K-shots (examples of input and expected output).

For longer prompts, a common practice is to use XML notation to break up sections like persona, task instructions, response format, etc.

I like to use XML for single-record structured outputs… I’ll tell the model reply using XML syntax including the following fields: … and then I list the fields I am expecting to parse out of the model’s reply. Of course if you want many records to be produced, or they are complex with lots of validation rules, then use structured outputs or function call parameters.

Happy tokens!

1 Like