cli/resources/embeddings/index.md +0 −172 deleted
File Deleted View Diff
1# Embeddings
2
3## Create embeddings
4
5`$ openai embeddings create`
6
7**post** `/embeddings`
8
9Creates an embedding vector representing the input text.
10
11### Parameters
12
13- `--input: string or array of string or array of number or array of array of number`
14
15 Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.
16
17- `--model: string or EmbeddingModel`
18
19 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
20
21- `--dimensions: optional number`
22
23 The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.
24
25- `--encoding-format: optional "float" or "base64"`
26
27 The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).
28
29- `--user: optional string`
30
31 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
32
33### Returns
34
35- `create_embedding_response: object { data, model, object, usage }`
36
37 - `data: array of Embedding`
38
39 The list of embeddings generated by the model.
40
41 - `embedding: array of number`
42
43 The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](https://platform.openai.com/docs/guides/embeddings).
44
45 - `index: number`
46
47 The index of the embedding in the list of embeddings.
48
49 - `object: "embedding"`
50
51 The object type, which is always "embedding".
52
53 - `model: string`
54
55 The name of the model used to generate the embedding.
56
57 - `object: "list"`
58
59 The object type, which is always "list".
60
61 - `usage: object { prompt_tokens, total_tokens }`
62
63 The usage information for the request.
64
65 - `prompt_tokens: number`
66
67 The number of tokens used by the prompt.
68
69 - `total_tokens: number`
70
71 The total number of tokens used by the request.
72
73### Example
74
75```cli
76openai embeddings create \
77 --api-key 'My API Key' \
78 --input 'The quick brown fox jumped over the lazy dog' \
79 --model text-embedding-3-small
80```
81
82#### Response
83
84```json
85{
86 "data": [
87 {
88 "embedding": [
89 0
90 ],
91 "index": 0,
92 "object": "embedding"
93 }
94 ],
95 "model": "model",
96 "object": "list",
97 "usage": {
98 "prompt_tokens": 0,
99 "total_tokens": 0
100 }
101}
102```
103
104## Domain Types
105
106### Create Embedding Response
107
108- `create_embedding_response: object { data, model, object, usage }`
109
110 - `data: array of Embedding`
111
112 The list of embeddings generated by the model.
113
114 - `embedding: array of number`
115
116 The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](https://platform.openai.com/docs/guides/embeddings).
117
118 - `index: number`
119
120 The index of the embedding in the list of embeddings.
121
122 - `object: "embedding"`
123
124 The object type, which is always "embedding".
125
126 - `model: string`
127
128 The name of the model used to generate the embedding.
129
130 - `object: "list"`
131
132 The object type, which is always "list".
133
134 - `usage: object { prompt_tokens, total_tokens }`
135
136 The usage information for the request.
137
138 - `prompt_tokens: number`
139
140 The number of tokens used by the prompt.
141
142 - `total_tokens: number`
143
144 The total number of tokens used by the request.
145
146### Embedding
147
148- `embedding: object { embedding, index, object }`
149
150 Represents an embedding vector returned by embedding endpoint.
151
152 - `embedding: array of number`
153
154 The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](https://platform.openai.com/docs/guides/embeddings).
155
156 - `index: number`
157
158 The index of the embedding in the list of embeddings.
159
160 - `object: "embedding"`
161
162 The object type, which is always "embedding".
163
164### Embedding Model
165
166- `embedding_model: "text-embedding-ada-002" or "text-embedding-3-small" or "text-embedding-3-large"`
167
168 - `"text-embedding-ada-002"`
169
170 - `"text-embedding-3-small"`
171
172 - `"text-embedding-3-large"`