Learn how to use all 14 Ollama API endpoints with real-world examples, best practices, and production-ready insights.
Artificial Intelligence is rapidly moving from cloud-only environments to local deployments. Developers increasingly want privacy, lower latency, reduced costs, and complete control over their AI infrastructure.
This is where Ollama shines.
Ollama allows you to run powerful Large Language Models (LLMs) such as Llama, Gemma, Mistral, Qwen, DeepSeek, and many others directly on your local machine or server. Beyond running models, Ollama provides a robust REST API that enables developers to integrate AI capabilities into applications, automation workflows, chatbots, coding assistants, search engines, and enterprise systems.
In this guide, you'll learn all 14 Ollama API endpoints, understand when to use each one, and see practical examples that go beyond the official documentation.
Ollama is a platform designed to simplify the deployment and execution of large language models locally.
Some advantages include:
By default, Ollama runs on:
http://localhost:11434
POST /api/generate
Generates text from a single prompt.
curl http://localhost:11434/api/generate \
-d '{
"model":"llama3",
"prompt":"Explain quantum computing in simple terms."
}'
Use /api/generate
for one-shot tasks where conversation history is unnecessary. It consumes fewer resources than chat endpoints.
POST /api/chat
Maintains conversational context.
curl http://localhost:11434/api/chat \
-d '{
"model":"llama3",
"messages":[
{
"role":"user",
"content":"Create a Node.js REST API."
}
]
}'
For production chat applications, always store conversation history externally rather than relying solely on the model context window.
POST /api/embeddings
Converts text into numerical vectors.
curl http://localhost:11434/api/embeddings \
-d '{
"model":"nomic-embed-text",
"prompt":"How does machine learning work?"
}'
Embeddings are the foundation of modern Retrieval-Augmented Generation (RAG) systems.
GET /api/tags
Displays all downloaded models.
curl http://localhost:11434/api/tags
Useful for:
POST /api/show
Returns detailed model information.
curl http://localhost:11434/api/show \
-d '{
"name":"llama3"
}'
Use this endpoint to automatically validate model compatibility before deployment.
POST /api/pull
Downloads a model from the Ollama registry.
curl http://localhost:11434/api/pull \
-d '{
"name":"deepseek-r1"
}'
When deploying a new server:
startup.sh
can automatically pull required models before application startup.
POST /api/push
Publishes a model to a registry.
curl http://localhost:11434/api/push \
-d '{
"name":"mycompany-assistant"
}'
POST /api/create
Creates custom models from a Modelfile.
curl http://localhost:11434/api/create \
-d '{
"name":"seo-expert",
"modelfile":"FROM llama3"
}'
You can:
POST /api/copy
Duplicates an existing model.
curl http://localhost:11434/api/copy \
-d '{
"source":"llama3",
"destination":"llama3-backup"
}'
DELETE /api/delete
Removes a model from local storage.
curl -X DELETE http://localhost:11434/api/delete \
-d '{
"name":"old-model"
}'
Always verify model usage before deleting in shared environments.
GET /api/ps
Shows models currently loaded in memory.
curl http://localhost:11434/api/ps
Helpful for:
Large models may occupy several gigabytes of RAM even when idle.
GET /api/version
Returns the installed Ollama version.
curl http://localhost:11434/api/version
Useful for:
POST /v1/chat/completions
Provides OpenAI API compatibility.
curl http://localhost:11434/v1/chat/completions \
-d '{
"model":"llama3",
"messages":[
{
"role":"user",
"content":"Write a Python function for sorting."
}
]
}'
Applications built for OpenAI can often switch to Ollama with minimal code changes.
GET /v1/models
Lists available models using the OpenAI format.
curl http://localhost:11434/v1/models
Many developers stop at generating text, but modern AI applications usually combine several endpoints:
/api/chat
/api/show
/api/ps
/api/embeddings
/api/chat
/api/pull
/api/show
/api/chat
/api/delete
/v1/chat/completions
/v1/models
Combining endpoints intelligently is what separates a proof of concept from a production-ready AI solution.
Before exposing Ollama publicly:
Never expose an unrestricted Ollama instance directly to the internet.
To achieve better performance:
These practices can significantly reduce latency and improve throughput.
Ollama is much more than a tool for running local language models, it is a complete AI platform with endpoints covering text generation, conversational AI, embeddings, model lifecycle management, monitoring, and OpenAI compatibility.
Understanding all 14 endpoints allows developers to build sophisticated AI solutions without relying entirely on external providers. Whether you're creating a chatbot, a RAG-powered knowledge base, a coding assistant, or an enterprise AI platform, Ollama provides the building blocks needed to deploy AI locally, securely, and efficiently.
As organizations increasingly prioritize privacy, cost control, and infrastructure ownership, mastering the Ollama API is becoming a valuable skill for modern software engineers, DevOps professionals, and AI developers.