How to program the ChatGPT API using Python?

Hello everyone, I have a question about calling the GPT-4 API.

I would like the ChatGPT role to assume the persona of a professional and provide a response based on the format of my input. Below is the structure of the program I’ve written.

Could you please confirm if it’s correct?

system_prompt refers to the role I’m asking GPT-4 to assume and the way it should respond to the questions. input_text is the content I’m providing for GPT-4 to respond to.

  • response = openai.ChatCompletion.create(
  • model=“gpt-4”,
  • messages=[

{“role”: “system”, “content”: system_prompt},


* ```
{"role": "user", "content": input_text}
  • ]
  • )

However, I am still a bit confused about the differences between roles like “system,” “user,” and “assistant.” What are the distinctions between these roles?

Thank you