Formatting API responses... (theory)

Hi everyone,

I have a question that is a bit more theoretical at this point in time (for me at least). I am really cooking with gas now when it comes to my tool I created, works great. Things are going smooth. I am wondering though, when it comes to posting the OpenAI API response to an output, has anyone played around with formatting it to bold/italic/underline, etc…

I have already implemented my tool to add line breaks accordingly when it posts to the output… for example, when the paragraph it returns is large, or there is a numbered list, etc… the API has built in line breaks like that.

Although when I have been playing around with it, I do not believe 3.5-turbo sends back a response with any type of underlying formatting recommendations when posting the response. I was thinking of building it into my prompt logic (sorry… “messages” logic… lol), so that the model will respond with what it possibly thinks could be bolded, or underlined, etc… but if it follows those directions so that my javascript de-codes it to post it to the output properly… that is what I am wondering. For example:

Using the following conventions to format your response, answer the following question:

  • For bold text, use asterisks around the text
  • For italic text, use underscores around the text
  • For underlined text, use +plus signs+ around the text

Has anyone been successful in this?

If so let me know, I don’t want to spend the time on this if someone has tried and failed already. If it has worked for someone, then yes I will give it a go, and if successful I can post how I did it for future reference to help someone.


You need to ask the API to write using “markdown format”.

There are libraries available to convert markdown to HTML and back again