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

**URL:** https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073
**Category:** Prompting
**Created:** [March 9, 2023, 12:59pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073 "2023-03-09T12:59:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Kostarica](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/kostarica/32/37637_2.png) [@Kostarica](https://community.openai.com/u/Kostarica)
#### Post date: [March 9, 2023, 12:59pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/1 "2023-03-09T12:59:30Z")

</div>

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?

```auto
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(
    engine=model,
    prompt=prompt,
    temperature=temperature,
    max_tokens=max_tokens,
    format=format
)

output_text = response.choices[0].text
print(output_text)

```

---

<div class="post-metadata">

### Author: ![pinardalec](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/pinardalec/32/25711_2.png) [@pinardalec](https://community.openai.com/u/pinardalec)
#### Post date: [March 9, 2023, 2:07pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/2 "2023-03-09T14:07:49Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sps](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sps/32/7736_2.png) [@sps](https://community.openai.com/u/sps)
#### Post date: [March 9, 2023, 6:29pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/3 "2023-03-09T18:29:01Z")

</div>

Hi,

There’s no `format` parameter in the docs.

Always refer to [docs](https://platform.openai.com/docs/api-reference/chat/create)

---

<div class="post-metadata">

### Author: ![rajat.kumar3](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/rajat.kumar3/32/11659_2.png) [@rajat.kumar3](https://community.openai.com/u/rajat.kumar3)
#### Post date: [May 16, 2023, 9:34am UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/4 "2023-05-16T09:34:14Z")

</div>

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”.

---

<div class="post-metadata">

### Author: ![rmalpe](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/rmalpe/32/146764_2.png) [@rmalpe](https://community.openai.com/u/rmalpe)
#### Post date: [July 8, 2024, 11:17am UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/5 "2024-07-08T11:17:24Z")

</div>

@Kostarica

you can do this hack

```python
import markdown2
gpt_response="The latest reviews for Hotel Jagdamba are: \n1. \"Best Hotel With Best service\"\n2. \"Quality is too good 👍\"\n3. \"Test was good.\""

text='### '+gpt_response

print(markdown2.markdown(f"""{text}"""))

<h3>The latest reviews for Hotel Jagdamba are:</h3>

<ol>

<li>"Best Hotel With Best service"</li>

<li>"Quality is too good 👍"</li>

<li>"Test was good."</li>

</ol>
```

---

<div class="post-metadata">

### Author: ![ajarnspencer](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ajarnspencer/32/194486_2.png) [@ajarnspencer](https://community.openai.com/u/ajarnspencer)
#### Post date: [July 8, 2024, 6:01pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/6 "2024-07-08T18:01:17Z")

</div>

The answer is a big YES. I do it all the time in GPT Chat Interface, hence you can do it with your own LLM model/GPT. The art is in the prompt only no need for the python code, just set rules as to how to output and format its plain text answer (i.e. use exclamation mark (!) and alt in square brackets, with an image url in parentheses to display an image in Markdown, if and when GPT outputs it as plain text, instead of its own markdown… right?) - . I also let it display full blogposts with formatted text and images, or can get it to display me a blogpost in html container tags, and even re-explain (not translate, rather re-explain in the indigenous form of a language), all the human readable content, alt and title tags, and other human readable or meta data related translatable text within the html code to be transposed into different languages. I have some sophisticated prompts developed to do this. It wont display video for me yet though in the chat interface… but i can get a decent visual copy and paste for quick mini-blogging, or pasting into a rich text editor and save as pdf, as well as for reblogging the same content in multiple languages whilst maintaining a uniform format

 ![CaptureChatgpt2](https://us1.discourse-cdn.com/openai1/original/4X/d/7/8/d7878f53c38327be09e03a9fef0b54eb6344a757.jpeg)  
 ![english](https://us1.discourse-cdn.com/openai1/original/4X/f/9/a/f9a631360dee301b839392662d14747c2b559ac8.jpeg)  
 ![viet](https://us1.discourse-cdn.com/openai1/original/4X/9/a/9/9a947ae4021e043137c7f25ceebf9f472eed8f8a.jpeg)  
 ![viet-html](https://us1.discourse-cdn.com/openai1/original/4X/a/e/f/aef2a264b8914a0f79f638120bfa87c6ed1e4972.jpeg)  
p.s. Sorry if i do not share the prompts.

---

<div class="post-metadata">

### Author: ![grandell1234](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/grandell1234/32/286916_2.png) [@grandell1234](https://community.openai.com/u/grandell1234)
#### Post date: [July 8, 2024, 6:05pm UTC](https://community.openai.com/t/is-it-possible-to-get-the-response-text-in-html-format/91073/7 "2024-07-08T18:05:04Z")

</div>


