api.md 1.27 KB
Newer Older
1
2
3
4
5
[Documentation Home](./README.md)

# API

## Generate a Prompt
Matt Williams's avatar
Matt Williams committed
6
**POST /api/generate**
7

Matt Williams's avatar
Matt Williams committed
8
9
**Generate** is the main endpoint that you will use when working with Ollama. This is used to generate a response to a prompt sent to a model.

Matt Williams's avatar
Matt Williams committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
The **Generate** endpoint takes a JSON object with the following fields:

```
{
  Model: "modelname",
  Prompt: "prompt",
  Context: "context",
}
```

Context is optional, but is used to provide additional context, such as memory of earlier prompts. 

The response is a stream of JSON objects with the following fields:

```
{
  "model": "modelname",
  "created_at": "2023-08-04T08:52:19.385406455-07:00"
  "response": "the current token",
  "done": false
}
```

| field | description |
| --- | --- |
| model | the name of the model |
| created_at | the time the response was generated |
| response | the current token |
| done | whether the response is complete |
39
## Create a Model
Matt Williams's avatar
Matt Williams committed
40
**POST /api/create**
41
42

## List Local Models
Matt Williams's avatar
Matt Williams committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
**GET /api/tags**

### Return Object
```
{
  "models": [
    {
      "name": "modelname:tags",
      "modified_at": "2023-08-04T08:52:19.385406455-07:00",
      "size": size
    }
  ]

}
```
58
59
60
61

## Copy a Model
**/api/copy**

Matt Williams's avatar
Matt Williams committed
62
63
64
## Delete a Model
**/api/delete**

65
66
67
68
## Pull a Model
**/api/pull**

## Push a Model
Matt Williams's avatar
Matt Williams committed
69
70
71
72
73
**/api/push**

## Heartbeat
**/**