Tech Tip: Understanding “roles” in AI Conversations
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: October 6, 2025
When working with the chat.completions.create command in 4D AIKit component, each message is assigned a role that defines who is speaking and how the AI should respond. Correctly using roles ensures consistent behavior and tone in AI interactions.
The three roles are :
Example :
Here's an example of how to use these roles to form a single conversation flow.
Result :

By combining multiple message roles, it becomes possible to control both the tone and logic of AI conversations, ensuring responses that remain clear, consistent, and aligned with the intended style.
The three roles are :
- "system" – Defines AI Behavior :
- "user" – Represents Human Input :
- "assistant" – Represents AI Output :
Provides global instructions that set the tone, style, or behavior of the AI.
{role; "system"; content; "Act as a helpful support agent."} |
Functions as a “job description” for the AI.
Contains the message or question to be analyzed or answered.
{role"; "user"; content; "How can I reset my password?"} |
Holds the AI’s previous responses. Including these messages helps maintain conversation context.
{role; "assistant"; content; "Click 'Forgot Password' on the login screen."} |
Example :
Here's an example of how to use these roles to form a single conversation flow.
var $client:=cs.AIKit.OpenAI.new($apiKey) var $messages:=[] //New object command can be used as well $messages.push(New object("role"; "system"; "content"; "Act as a helpful support agent.")) $messages.push({role: "user"; content: "How can I reset my password?"}) var $result:=$client.chat.completions.create($messages; {model: "gpt-4o-mini"}) ALERT($result.choice.message.text) |
Result :

By combining multiple message roles, it becomes possible to control both the tone and logic of AI conversations, ensuring responses that remain clear, consistent, and aligned with the intended style.