API Call response is returned in one big paragraph not structured

Hey Community,

I have been working on OpenAI’s API for one week and there is one issue I am facing. The issue is When I call openAI’s API against my custom data, it gives me an unstructured response which I am rendering on the front end of my application.

My question is, Do we need to structure the returned data on the frontend or is it related to the backend API always returning the response in a structured manner and I have to manage prompts better at the backend?


1 Like

You can ask the model to return you a structured response. A common practice when building LLM applications is to have AI output json. You can use 1106 family of models (3.5 and 4) for that with the output set to json in the parameters.

1 Like

When you say not structured, do you mean no newline, etc? If so and your application is web based, you can simply add this css to the div displaying the output text:

white-space: pre-wrap;

The APIs usually output in markdown format. You can also use other markdown display library/component specially if there are links/images/lists in your output.


Can you elaborate a bit as I am still new to using OpenAI APIs for responses?

[your prompt]

Return a properly formatted JSON data with the following fields: ...
1 Like