Multi-turn conversations allow you to maintain context across multiple exchanges by including conversation history in your API requests. This enables the model to understand and reference previous messages, creating natural, coherent dialogues.
Each API request includes an array of previous messages. The model uses this history to understand context and maintain coherence across the conversation:
# First exchangemessages = [ {"role": "user", "content": "What is the capital of France?"}]# Response: "The capital of France is Paris."# Second exchange - model remembers Parismessages = [ {"role": "user", "content": "What is the capital of France?"}, {"role": "assistant", "content": "The capital of France is Paris."}, {"role": "user", "content": "What's the population?"}]# Response: "As of the latest estimates, the population of Paris is approximately 2.2 million..."
Note: You’re responsible for managing conversation history. Each request must include all relevant previous messages - the API doesn’t store history between requests.
The LLM Gateway accepts POST requests to https://llm-gateway.assemblyai.com/v1/chat/completions with the following parameters:
curl -X POST \ "https://llm-gateway.assemblyai.com/v1/chat/completions" \ -H "Authorization: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [ { "role": "user", "content": "What is the capital of France?" }, { "role": "assistant", "content": "The capital of France is Paris." }, { "role": "user", "content": "What'\''s the population?" } ], "max_tokens": 1000 }'
The API returns a JSON response with the model’s completion:
{ "request_id": "abc123", "choices": [ { "message": { "role": "assistant", "content": "As of the latest estimates, the population of Paris is approximately 2.2 million people within the city proper, and around 12 million in the greater metropolitan area." }, "finish_reason": "stop" } ], "request": { "model": "claude-sonnet-4-6", "max_tokens": 1000 }, "usage": { "input_tokens": 45, "output_tokens": 35, "total_tokens": 80 }}