Preserving White Space in API Responses

I am using gpt-3.5 to take a large chunk of text and segment it with ###'s (for better chunking later) and return it as markdown while preserving any indentations (specifically bullets and sub bullet lists). When i run it through the chat interface and playground it works as expected however, when i run it through the api, i lose all the indentations in the response (the segmenting works as expected).

Is there something i’m missing to preserve whitespace over api calls?

For web apps, to preserve the white-space when you display the api output, add the following CSS to the HTML element that contains the text:

white-space: pre-wrap;

So long as you are including the spaces in your API message string, they should get tokenised, there are a great many unique tokens for sequences of spaces of all different lengths, if you are loosing spaces I would check for “strip” commands that may be removing leading or trailing spaces or space removing regex or other formatting changes.