Is it possible to get the response text in HTML format?

At the moment, we get the output text by API unformatted.
ChatGPT replied to use the format=“html” parameter, but that parameter didn’t work.
The question is, maybe there is an option how to get the formatted text, or maybe there is some other way?

import openai

openai.api_key = "YOUR_API_KEY"

prompt = "Generate a short story about a haunted house."
model = "text-davinci-002"
temperature = 0.5
max_tokens = 50
format = "html"

response = openai.Completion.create(

output_text = response.choices[0].text

What are you expecting ?

You could always preprend your prompt with “Answer should be embedded in html tags.” for example.

prepend = "Answer should be embedded in html tags. "
prompt = preprend + prompt

1 Like


There’s no format parameter in the docs.

Always refer to docs

1 Like

Yes, you can get the response text in html, json, xml, knowledge graphs etc. But there is no explicit setting or parameter for it. You need to add instruction to do so. For instance, “Please do the html formatting of the content”.