Skip to main content
Leverage the Ollama REST API to integrate large language models (LLMs) into your applications over HTTP. Skip the CLI or chatbot UI—simply send requests to interact with models for text generation, conversational chat, and model management.

Generate Endpoint

The POST /api/generate endpoint returns a model’s completion for your prompt.
By default, "stream": false delivers the full response at once. Set "stream": true to receive incrementally streamed data (word or phrase by phrase), emulating the gradual output of web chat interfaces.
Streaming responses can improve perceived latency for long completions. Be sure your client can handle partial chunks.

Formatting the JSON Output

You can instruct Ollama to structure its response using a format schema:

Sample Response

  • title and theme are strings.
  • lines is an array of strings—ideal for rendering multiline content.

Chat Endpoint

Use POST /api/chat to maintain conversational context. Provide an array of messages with roles (user or assistant).

Example Response

Here, repeated initial sounds like s in “silicon sanctums, sparks” and l in “Language learning lattices” provide alliteration.

Model Management Endpoints

Ollama’s REST API also lets you list, inspect, copy, delete, and pull models without switching to the CLI.
The image shows a list of API endpoints with three options: listing running models, seeing details of a model, and deleting or pulling a new model.

Endpoint Summary

Usage Examples

Deleting a model is irreversible. Ensure you specify the correct model name to avoid accidental data loss.

Full API Reference

For a complete list of endpoints and detailed parameters, see the official API documentation.
The image shows a "Next Steps" section with a URL link to a GitHub page related to API documentation.

Next, we’ll demonstrate how to call these endpoints programmatically using an OpenAI-compatible client library. Stay tuned!

Watch Video