Understanding Role Management in OpenAI's API: Two Methods Compared

Hi guys, I’ve been using ChatGPT-4 extensively for about two months and it has been very helpful in my day-to-day activities. In fact, I’m currently developing a web application and plan to use its API.

I already had programming experience in a few languages, but I had never programmed professionally before, just simple programs for personal use and in my research (I’m a mathematics researcher) - mostly around 100 lines of code.

Before ChatGPT-4, I had never written a line of JavaScript. Now, I’ve created a prototype with a frontend .html file, a backend .js file, and using the OpenAI API, and it works! I’ve already got around 700 lines of code without writing a single line myself - this is unbelievable!

I have a question for you. The Chat API has possible “roles”: system, assistant, and user. Let’s say I want to issue an instruction with a predefined string A, followed by the user input B. I can do this in two ways:
Method 1: role=user; message=A+B;
Method 2: role=system, message=A; role=user, message=B.

From the few tests I’ve done, it seems to give the same result. The only difference I saw is organizational - Method 2 is more structured and is probably better for scaling. Do you know if there is actually a difference between the two methods? Do you have any simple and concrete examples of this difference that I could test?

PS.: I’m Brazilian, and my english still needs improved, the above message (but not this PS) was translated and improved with chatgpt4.


System role: Allows you to specify the way the model answers questions. Classic example: “You are a helpful assistant.”

User role: Equivalent to the queries made by the user.

Assistant role: are the model’s responses (based on the user messages)

You always have to keep in mind the meaning of the roles and generate specific content for each one.

I believe that specific and short indications is the ideal and optimal.


Thanks for the answer, it was quite useful. Do you have any source of this information? I need to document this somewhere.

More info an code examples: https://platform.openai.com/docs/guides/gpt/chat-completions-api