summaryrefslogtreecommitdiffhomepage
path: root/.rules/docs/ollama/embed.md
blob: 9c81ebf756da68efd58350282da27c3028a6f9d5 (plain)
1
2
3
4
5
6
7
8
9
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Generate embeddings

`POST /api/embed` — Creates vector embeddings representing the input text.

**Server:** `http://localhost:11434`

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `model` | string | yes | Model name (e.g. `"embeddinggemma"`) |
| `input` | string \| string[] | yes | Text or array of texts to embed |
| `truncate` | boolean | no | Truncate inputs exceeding context window (default: `true`). If `false`, returns an error. |
| `dimensions` | integer | no | Number of dimensions for the embedding vectors |
| `keep_alive` | string | no | Model keep-alive duration |
| `options` | ModelOptions | no | Runtime options (see generate.md) |

## Response

| Field | Type | Description |
|---|---|---|
| `model` | string | Model that produced the embeddings |
| `embeddings` | number[][] | Array of embedding vectors (one per input) |
| `total_duration` | integer | Total time (nanoseconds) |
| `load_duration` | integer | Model load time (nanoseconds) |
| `prompt_eval_count` | integer | Number of input tokens processed |

## Examples

### Single input
```bash
curl http://localhost:11434/api/embed -d '{
  "model": "embeddinggemma",
  "input": "Why is the sky blue?"
}'
```

### Multiple inputs (batch)
```bash
curl http://localhost:11434/api/embed -d '{
  "model": "embeddinggemma",
  "input": [
    "Why is the sky blue?",
    "Why is the grass green?"
  ]
}'
```

### Custom dimensions
```bash
curl http://localhost:11434/api/embed -d '{
  "model": "embeddinggemma",
  "input": "Generate embeddings for this text",
  "dimensions": 128
}'
```