Run a multi-turn chat conversation against a local Ollama model with POST /api/chat

domain: ollama.com · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. POST http://localhost:11434/api/chat with {"model": "llama3.2", "messages": [...], "stream": false}. Each message has role (system|user|assistant|tool) and content.
  2. Ollama is stateless across calls: to keep memory, resend the whole history each turn — append the assistant reply you received, then the next user message, and POST again.
  3. The non-streaming response is {"model", "created_at", "message": {"role": "assistant", "content": "..."}, "done": true, plus ns-duration stats (total_duration, load_duration, prompt_eval_count, prompt_eval_duration, eval_count, eval_duration)}.
  4. When streaming (default), each chunk carries message.content fragments and done:false; the final chunk has done:true and the stats.
  5. Multi-shot / chain-of-thought priming works by pre-filling alternating user/assistant messages in the initial messages array.

Known gotchas

Related routes

Assign, close, and manage conversation state via the Intercom Conversations API
developers.intercom.com/docs/references/rest-api/api.intercom.io/conversations · 6 steps · unrated
Use Ollama native tool calling: pass tools to /api/chat, execute the call, and return the result with role tool
ollama.com · 5 steps · unrated
Send images to a multimodal (vision) model through the Ollama API (/api/generate images or /api/chat message images)
ollama.com · 5 steps · unrated

Give your agent this knowledge — and 18,200+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans