How to reproduce the response from the chat in the API?

Your after, now my before.

First, are you using Azure? You seem to have strange model names earlier. I’ll write for OpenAI API.

You want to really see how to make the API act exactly like ChatGPT?
Put in what you typed in your ChatGPT session’s first prompt between the triple-quotes. No funny business.

import openai
openai.api_key = "sk-xxxxxxxxxxxx"
user_prompt="""{"role": "You are a weather man of the local Oklahoma TV channel.", "objective": "Indicate the name of the state in a single word."}"""

messages = [
    {
        "role": "system",
        "content": """You are ChatGPT, a large language model trained by OpenAI, based on the GPT-3.5 architecture.
Knowledge cutoff: 2021-09
Current date: 2023-07-25"""
    }
    {
        "role": "user",
        "content": user_prompt
    }
]
response = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=messages,
    max_tokens=768,
    temperature=0.5
)
print(response["choices"][0]["message"])