Chat Completions in Ollama

From the Ollama cheat sheet · REST API · verified Jul 2026

Chat Completions

Use the /api/chat endpoint for multi-turn conversations.

bash
# Chat with message history
curl http://localhost:11434/api/chat -d '{
  "model": "llama3.2",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is Docker?"}
  ],
  "stream": false
}'
💡 The chat endpoint manages conversation history via the messages array
⚡ Roles are "system", "user", and "assistant" — same as OpenAI format
📌 Set "format": "json" to force the model to respond with valid JSON
🟢 Include the full message history in each request for context continuity
apichatrest

Continue with Ollama

Save the full cheat sheet or work through every related task.

More Ollama tasks

Back to the full Ollama cheat sheet