# How do I use the new JSON mode?

**URL:** <https://community.openai.com/t/how-do-i-use-the-new-json-mode/475890>\
**Category:** API\
**Tags:** api\
**Created:** [November 6, 2023, 10:02pm UTC](https://community.openai.com/t/how-do-i-use-the-new-json-mode/475890 "2023-11-06T22:02:51Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![ryandetzel](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/ryandetzel/32/230184_2.png) [@ryandetzel](https://community.openai.com/u/ryandetzel)\
**Post date:** [November 6, 2023, 11:13pm UTC](https://community.openai.com/t/how-do-i-use-the-new-json-mode/475890/14 "2023-11-06T23:13:30Z")

</div>

```auto
import os
from openai import OpenAI
from google.colab import userdata

messages = [
  {"role": "system", "content": "List of months that have 30 days in json"},
]

client = OpenAI(api_key=userdata.get('OPENAI_API_KEY'))

response = completion = client.chat.completions.create(
  model="gpt-4-1106-preview",
  messages=messages,
  response_format= { "type":"json_object" }
)

print(completion.choices[0].message.content)

```

You have to have the response format AND you have to put the word json in your prompt

---

_[View the full topic](https://community.openai.com/t/how-do-i-use-the-new-json-mode/475890)._
