Skip to main content
A conversation is just a list of messages. You keep adding to it, send the whole list every time, and the model has full context of everything that came before.

The message shape

Every message has a role and content.

A working multi-turn

System prompt

The first system message sets the model’s persona and ground rules. It stays in the conversation, and you only write it once.
Python
Keep it short. Long system prompts cost more on every turn and tend to be ignored.

Stop reasons

The response tells you why the model stopped:

Keeping history under control

Messages add up fast. A few options:
  • Trim older turns when the conversation gets long. Keep the system message and recent N turns.
  • Summarize older turns into a single assistant message (“earlier you discussed: X, Y, Z”).
  • Use a separate structured output call to extract just the bits worth remembering, then drop the rest.

What’s next

Tool calling

Let the model invoke your tools mid-conversation.

Streaming

Stream the response token-by-token.

Vision & PDFs

Send images and documents as message content.

Drop-in SDKs

The auth and base URL setup.