The messages parameter defines your entire conversation so far — this is how you “teach” the model what has happened in the chat.
Each message is an object with two fields:
system (Optional, but Recommended)
Sets initial behavior, tone, or instructions for the assistant.
Example: "You are a helpful assistant."
user (Required)
Represents questions, requests, or inputs from the user.
Example: "Tell me about Indian classical music."
assistant (Optional, only for context in multi-turn)
Contains previous replies from the model, which help it stay consistent in tone and content.
Example: "Indian classical music is one of the oldest musical traditions..."
First, install the SDK:
Then use the following Python code: