Skip to main content
This example sends system and user messages, checks the HTTP result, and reads the assistant content and usage.

Extend the conversation

Append the assistant message and the next user message to the messages array. Your application owns Chat Completions history; trim or summarize it before the model’s context limit, and keep the original system policy.
For server-managed continuation on compatible routes, consider the Responses API. Still persist the state your product needs for auditability and recovery.
Last modified on July 13, 2026