Structured

Unstructured

While the OpenAI ChatGPT API communicates using JSON for requests and responses, the content of the messages within those JSON structures can be in various formats such as plain text, Python code, JSON, arrays, Markdown, and more.

How to Decide the Output Format

You can control the output format by providing clear instructions in your prompt. Here are some strategies:

  1. Direct Instructions: Clearly specify the desired format in your prompt.

Example: “Provide the result as a JSON object.”

  1. Use Explicit Language: Mention any formatting details.

Example: “Write a Python function that does X.”

  1. Specify Formatting Styles: Indicate if you want Markdown, code blocks, etc.

Example: “Give me a Markdown-formatted list of the top 5 programming languages.”

  1. Provide Templates: Offer a template or example in your prompt.

Example: “Format the output like this: {‘key1’: ‘value1’, ‘key2’: ‘value2’}.”