Web Asset House Guides
Local AI

Ollama /api/generate vs /api/chat: Which Endpoint to Use and Why

By Web Asset House Studio ·

Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.

How we wrote this: A plain-English summary of Ollama's official documentation (API reference), checked October 29, 2026.

Two ways to ask a model

Ollama's local API (http://localhost:11434) has two main text endpoints:

/api/generate /api/chat
Input One prompt string A messages array, each with a role and content
Output response text A message object with a role and content
Conversation You manage any context yourself You send the whole chat history each time
Tools No tools list for function calling
Extras system, suffix (fill-in-the-middle), raw, images format, options, think

Both accept model, stream (default true), format ("json" or a JSON schema), think and keep_alive. Both return timing fields such as total_duration and eval_count.

Minimal examples (from the docs)

curl http://localhost:11434/api/generate -d '{"model": "gemma4", "prompt": "Why is the sky blue?"}'
curl http://localhost:11434/api/chat -d '{"model": "gemma4", "messages": [{"role": "user", "content": "why is the sky blue?"}]}'

Replace gemma4 with a model you've pulled.

Which to use

Related: local API basics, structured outputs, usage metrics and errors, OpenAI-compatible API.

Sources

← All Local AI guides · All guides