Skip to content
Try chatGet API key

Generate embeddings

POST
/embeddings
curl --request POST \
--url https://api.bayle.ai/embeddings \
--header 'Accept-Language: pt-BR' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "text-embedding-qwen3-0-6b", "input": [ "The quick brown fox jumped over the lazy dog", "A fast auburn fox leapt over a sleepy hound" ], "dimensions": 32, "encoding_format": "float", "user": "user-1234" }'

Turns text into an embedding vector. Send a model and an input, which may be a single string or an array of strings to embed several inputs in one request. Fields Bayle does not name below are forwarded as sent, so a parameter your model supports but this document has not caught up with still reaches it.

Accept-Language
string
Example
pt-BR

Chooses the language of any error message in this request’s response. A tag beginning with the two letters pt, in any case, selects Brazilian Portuguese; anything else, including an absent header, selects English. The tag may appear anywhere in a multi-tag header, for example fr-FR;q=0.9,pt;q=0.5,en;q=0.3. Quality values are accepted but ignored, since this is a presence check rather than weighted negotiation.

Media typeapplication/json

The embedding request. Any field not listed here is forwarded as sent.

object
model
required

The embedding model to use, as returned by GET /models.

string
input
required
One of:
string
dimensions

Requests a specific output vector size, for models that support reducing it.

integer
encoding_format

How each vector is encoded in the response. Defaults to float.

string
Allowed values: float base64
user

Accepted for OpenAI client compatibility. Bayle does not act on this field.

string
key
additional properties
any
Examples

Several inputs, float vectors, reduced dimensions

{
"model": "text-embedding-qwen3-0-6b",
"input": [
"The quick brown fox jumped over the lazy dog",
"A fast auburn fox leapt over a sleepy hound"
],
"dimensions": 32,
"encoding_format": "float",
"user": "user-1234"
}

The embedding vectors for the supplied input.

Media typeapplication/json
object
object
string
model

The model that produced the vectors.

string
data

One entry per input, in the order the inputs were sent.

Array<object>
object
object
string
index
integer
embedding

The vector itself, or a base64 string when encoding_format was base64.

Array<number>
key
additional properties
any
usage
object
prompt_tokens
integer
total_tokens
integer
key
additional properties
any
key
additional properties
any
Examples

Float vectors for two inputs

{
"object": "list",
"model": "text-embedding-qwen3-0-6b",
"usage": {
"prompt_tokens": 24,
"total_tokens": 24
},
"data": [
{
"index": 0,
"object": "embedding",
"embedding": [
0.1447517,
-0.1780675,
-0.0238381,
-0.1826628,
0.0030695,
0.1527934,
0.0140013,
0.0959267,
-0.1596864,
0.0554307,
-0.1074149,
-0.2044905,
0.0554307,
-0.0268537,
-0.1665793,
0.1861093,
0.0588772,
0.1596864,
0.6203643,
-0.0047748,
-0.2113834,
0.1631328,
0.2458481,
0.2538898,
-0.0295822,
-0.2240204,
-0.0499738,
0.1734722,
0.1665793,
-0.0913314,
0.0496866,
-0.0173041
]
},
{
"index": 1,
"object": "embedding",
"embedding": [
0.1702173,
-0.2025899,
-0.0267596,
0.1399332,
0.0861529,
0.1785715,
0.1514203,
0.1660402,
0.0425543,
-0.0634399,
-0.2756893,
0.0190581,
0.0621345,
-0.022713,
-0.1472431,
0.2307854,
0.093985,
0.1837929,
0.4928991,
0.131579,
-0.3550544,
0.1321011,
0.199457,
0.3529659,
0.0684002,
-0.0898079,
0.0877193,
0.0139019,
0.1117377,
-0.0206245,
-0.0498643,
0.1075606
]
}
]
}
Content-Language
string
Allowed values: en pt-BR

Confirms which of the two supported locales, en or pt-BR, this response was rendered in, so a caller can detect it without reading the message text. Present on every response, success and error alike. On a chat completions stream it is committed together with the initial 200, so it appears whichever way the stream ends.

No credential was supplied, or the credential supplied is not valid. The request is rejected before any generation work begins. The body uses the shared error envelope, rendered in the negotiated locale.

Media typeapplication/json

Bayle’s OpenAI-shaped error envelope, shared by every error response this API returns.

object
error
required
object
message
required

A human-readable description of the failure, in the negotiated locale. See the Accept-Language request parameter for how that locale is chosen, and the Content-Language response header for which one was served.

string
type
required

OpenAI’s error type vocabulary, for example api_error, authentication_error, invalid_request_error, or rate_limit_error, matching the class of failure so an OpenAI SDK’s exception mapping keeps working.

string
param
required

The request field the failure names, when it names one. Null when the failure is not field-specific, as with authentication or rate limiting.

string
nullable
code
required

Bayle’s semantic error code, reusing OpenAI’s vocabulary where an equivalent exists, for example invalid_api_key or rate_limit_exceeded. Null when Bayle could not identify the specific failure; the envelope is still valid and carries a generic message. The full list lives in Bayle’s error reference rather than being enumerated here.

string
nullable
Examples

English (default)

{
"error": {
"message": "Your Bayle API key is missing or could not be verified.",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key"
}
}
Content-Language
string
Allowed values: en pt-BR

Confirms which of the two supported locales, en or pt-BR, this response was rendered in, so a caller can detect it without reading the message text. Present on every response, success and error alike. On a chat completions stream it is committed together with the initial 200, so it appears whichever way the stream ends.

The request failed. The body uses the shared error envelope, rendered in the locale negotiated through Accept-Language. type and code identify the specific failure when Bayle recognizes it, and fall back to type: api_error with a null code when it does not. Where a failure carries a meaningful status code, Bayle preserves it; a transport failure, such as a timeout or a refused connection, is reported as 502. The exception is an operation that documents its own time limit, which reports running past it as 504 with the request_timeout code.

Media typeapplication/json

Bayle’s OpenAI-shaped error envelope, shared by every error response this API returns.

object
error
required
object
message
required

A human-readable description of the failure, in the negotiated locale. See the Accept-Language request parameter for how that locale is chosen, and the Content-Language response header for which one was served.

string
type
required

OpenAI’s error type vocabulary, for example api_error, authentication_error, invalid_request_error, or rate_limit_error, matching the class of failure so an OpenAI SDK’s exception mapping keeps working.

string
param
required

The request field the failure names, when it names one. Null when the failure is not field-specific, as with authentication or rate limiting.

string
nullable
code
required

Bayle’s semantic error code, reusing OpenAI’s vocabulary where an equivalent exists, for example invalid_api_key or rate_limit_exceeded. Null when Bayle could not identify the specific failure; the envelope is still valid and carries a generic message. The full list lives in Bayle’s error reference rather than being enumerated here.

string
nullable
Examples

400: a missing or invalid parameter, for example an unknown `type` on `GET /models`, no `input` on `POST /embeddings`, `n` above 1 or an unlisted `size` on `POST /images/generations`, a numeric or unlisted `duration` on the video endpoints, or no `queue_id`

{
"error": {
"message": "Bayle could not process this request because one or more parameters are invalid.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_request"
}
}
Content-Language
string
Allowed values: en pt-BR

Confirms which of the two supported locales, en or pt-BR, this response was rendered in, so a caller can detect it without reading the message text. Present on every response, success and error alike. On a chat completions stream it is committed together with the initial 200, so it appears whichever way the stream ends.