Conventions
Model names
Model names follow a model:tag format, where model can have an optional namespace such as example/model. Some examples are orca-mini:3b-q8_0 and llama3:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.
Durations
All durations are returned in nanoseconds.
Streaming responses
Certain endpoints stream responses as JSON objects. Streaming can be disabled by providing {"stream": false} for these endpoints.
Generate a completion
POST /api/generate
Generate a response for a given prompt with a provided model. This is a streaming endpoint, so there will be a series of responses. The final response object will include statistics and additional data from the request.
Parameters
model: (required) the model nameprompt: the prompt to generate a response forimages: (optional) a list of base64-encoded images (for multimodal models)
Advanced parameters (optional):
format: the format to return a response in. Can bejson.options: additional model parameters liketemperaturesystem: system message (overrides model file)template: prompt template (overrides model file)stream: iffalsethe response is returned as a single objectraw: iftrueno formatting is applied to the promptkeep_alive: controls how long the model stays loaded (default:5m)
Examples
Request (Streaming)
curl http://localhost:11434/api/generate -d '{
"model": "llama3",
"prompt": "Why is the sky blue?"
}'
Response
{
"model": "llama3",
"created_at": "2023-08-04T08:52:19.385Z",
"response": "The",
"done": false
}
Generate a chat completion
POST /api/chat
Generate the next message in a chat with a provided model.
Parameters
model: (required) the model namemessages: a list of messages, each withroleandcontent
Examples
Request
curl http://localhost:11434/api/chat -d '{
"model": "mistral",
"messages": [
{ "role": "user", "content": "why is the sky blue?" }
]
}'
Create a Model
POST /api/create
Create a model from a Modelfile.
Parameters
model: (required) name of the model to createpath: path to the Modelfilestream: iffalsethe response is a single object
List Local Models
GET /api/tags
List models that are available locally.
Show Model Information
POST /api/show
Show details about a model including modelfile, template, parameters, and license.
Copy a Model
POST /api/copy
Copy a model. Creates a model with another name from an existing model.
Delete a Model
DELETE /api/delete
Delete a model and its data.
Pull a Model
POST /api/pull
Download a model from the ollama library.
Push a Model
POST /api/push
Upload a model to a model library.
Generate Embeddings
POST /api/embeddings
Generate embeddings from a model.
List Running Models
GET /api/ps
List models that are currently loaded into memory.
Version
GET /api/version
Retrieve the Ollama version.