The ChatGPT and GPT-4 models are optimized to work with inputs formatted as a conversation. The messages variable passes an array of dictionaries with different roles in the conversation delineated by system, user, and assistant.
https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart