rest-api-reference/inference/embeddings.md +0 −188 deleted
File Deleted View Diff
1#### Inference API
2
3# Embeddings
4
5***
6
7## POST /v1/embeddings
8
9Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests to embedding models.
10
11### Request Body
12
13* `dimensions` (integer | null) — The number of dimensions the resulting output embeddings should have.
14
15* `encoding_format` (string | null) — The format to return the embeddings in. Can be either \`float\` or \`base64\`.
16
17* `input` (object | object | object | object)
18
19 * `String` (string, required) — A strings to be embedded. For best performance, prepend "query: " in front of query content and prepend "passage: " in front of passage/text
20
21 * `StringArray` (array\<string>, required) — An array of strings to be embedded
22
23 * `Ints` (array\<integer>, required) — A token in integer to be embedded
24
25 * `IntsArray` (array\<array\<integer>>, required) — An array of tokens in integers to be embedded
26
27* `model` (string) — ID of the model to use.
28
29* `preview` (boolean | null) — Flag to use the new format of the API.
30
31* `user` (string | null) — A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.
32
33### Response Body
34
35* `data` (array\<object>, required) — A list of embedding objects.
36
37 * `embedding` (string | array\<number>, required)
38
39 * `index` (integer, required) — Index of the embedding object in the data list.
40
41 * `object` (string, required) — The object type, which is always \`"embedding"\`.
42
43* `model` (string, required) — Model ID used to create embedding.
44
45* `object` (string, required) — The object type of \`data\` field, which is always \`"list"\`.
46
47* `usage` (object)
48
49 * `prompt_tokens` (integer, required) — Prompt token used.
50
51 * `total_tokens` (integer, required) — Total token used.
52
53\*\*Request example:\*\*
54
55```json
56"{\n \"input\": [\"This is an example content to embed...\"],\n \"model\": \"v1\",\n \"encoding_format\": \"float\"\n }"
57```
58
59\*\*Response example:\*\*
60
61```json
62{
63 "object": "list",
64 "model": "v1",
65 "data": [
66 {
67 "index": 0,
68 "embedding": [
69 0.01567895,
70 0.063257694,
71 0.045925662
72 ],
73 "object": "embedding"
74 }
75 ],
76 "usage": {
77 "prompt_tokens": 1,
78 "total_tokens": 1
79 }
80}
81```
82
83***
84
85## GET /v1/embedding-models
86
87List all embedding models available to the authenticating API key with full information. Additional information compared to /v1/models includes modalities, fingerprint and alias(es).
88
89### Response Body
90
91* `models` (array\<object>, required) — Array of available embedding models.
92
93 * `aliases` (array\<string>, required) — Alias ID(s) of the model that user can use in a request's model field.
94
95 * `created` (integer, required) — Model creation time in Unix timestamp.
96
97 * `fingerprint` (string, required) — Fingerprint of the xAI system configuration hosting the model.
98
99 * `id` (string, required) — Model ID. Obtainable from \<https://console.x.ai/team/default/models> or \<https://docs.x.ai/docs/models>.
100
101 * `input_modalities` (array\<string>, required) — The input modalities supported by the model.
102
103 * `object` (string, required) — Object type, should be model.
104
105 * `output_modalities` (array\<string>, required) — The output modalities supported by the model.
106
107 * `owned_by` (string, required) — Owner of the model.
108
109 * `prompt_image_token_price` (integer, required) — Price of the prompt image token in USD cents per million token.
110
111 * `prompt_text_token_price` (integer, required) — Price of the prompt text token in USD cents per million token.
112
113 * `version` (string, required) — Version of the model.
114
115\*\*Response example:\*\*
116
117```json
118{
119 "models": [
120 {
121 "id": "v1",
122 "fingerprint": "fp_df37966059",
123 "created": 1725148800,
124 "object": "model",
125 "owned_by": "xai",
126 "version": "0.1.0",
127 "input_modalities": [
128 "text"
129 ],
130 "prompt_text_token_price": 100,
131 "prompt_image_token_price": 0,
132 "aliases": []
133 }
134 ]
135}
136```
137
138***
139
140## GET /v1/embedding-models/\{model\_id}
141
142Get full information about an embedding model with its model\_id.
143
144### Path Parameters
145
146* `model_id` (string, required) — ID of the model to get.
147
148### Response Body
149
150* `aliases` (array\<string>, required) — Alias ID(s) of the model that user can use in a request's model field.
151
152* `created` (integer, required) — Model creation time in Unix timestamp.
153
154* `fingerprint` (string, required) — Fingerprint of the xAI system configuration hosting the model.
155
156* `id` (string, required) — Model ID. Obtainable from \<https://console.x.ai/team/default/models> or \<https://docs.x.ai/docs/models>.
157
158* `input_modalities` (array\<string>, required) — The input modalities supported by the model.
159
160* `object` (string, required) — Object type, should be model.
161
162* `output_modalities` (array\<string>, required) — The output modalities supported by the model.
163
164* `owned_by` (string, required) — Owner of the model.
165
166* `prompt_image_token_price` (integer, required) — Price of the prompt image token in USD cents per million token.
167
168* `prompt_text_token_price` (integer, required) — Price of the prompt text token in USD cents per million token.
169
170* `version` (string, required) — Version of the model.
171
172\*\*Response example:\*\*
173
174```json
175{
176 "id": "v1",
177 "created": 1725148800,
178 "object": "model",
179 "owned_by": "xai",
180 "version": "0.1.0",
181 "input_modalities": [
182 "text"
183 ],
184 "prompt_text_token_price": 10,
185 "prompt_image_token_price": 0,
186 "aliases": []
187}
188```