لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/ai/embeddings.md فهرس التوثيق — /llms.txt
مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.
Create embeddings
POST /v1/embeddings
Converts text into a vector representation. Vectors are used for semantic search, clustering, duplicate detection, and finding similar CRM cards. The request and response format is compatible with the OpenAI API. Streaming is not supported.
Embeddings are supported only by models whose capabilities.embeddings field equals true in GET /v1/models.
Request fields (body)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
Fieldmodel |
Typestring | Requiredyes | Default— | DescriptionIdentifier of a model that supports embeddings. List: GET /v1/models |
Fieldinput |
Typestring | string[] | Requiredyes | Default— | DescriptionText to vectorize: a single string or an array of 1 to 64 strings. One vector is returned per string. An empty string, an empty array, and an array longer than 64 strings are rejected with 400 |
Fieldencoding_format |
Typestring | Requiredno | Defaultfloat |
DescriptionFormat of the vector values: float or base64 |
Fielddimensions |
Typeinteger | Requiredno | Default— | DescriptionDesired vector dimensionality. For bitrix/embeddings, an integer from 32 to 4096: the vector is truncated to that many leading values and re-normalized to unit length. A value outside the range is rejected with 400 invalid_request. Other models receive the parameter unchanged and handle it according to their own rules |
Examples
curl — personal key
curl -X POST https://vibecode.bitrix24.com/v1/embeddings \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bitrix/embeddings",
"input": "We want a CRM for 50 users"
}'
curl — OAuth application
curl -X POST https://vibecode.bitrix24.com/v1/embeddings \
-H "X-Api-Key: YOUR_APP_KEY" \
-H "Authorization: Bearer USER_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "bitrix/embeddings",
"input": "We want a CRM for 50 users"
}'
JavaScript — personal key
const res = await fetch('https://vibecode.bitrix24.com/v1/embeddings', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'bitrix/embeddings',
input: ['First text', 'Second text'],
}),
})
const result = await res.json()
console.log(result.data.length) // 2 — one vector per string
console.log(result.data[0].embedding) // [0.0203, 0.0034, ...]
JavaScript — OAuth application
const res = await fetch('https://vibecode.bitrix24.com/v1/embeddings', {
method: 'POST',
headers: {
'X-Api-Key': 'YOUR_APP_KEY',
'Authorization': 'Bearer USER_SESSION_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'bitrix/embeddings',
input: ['First text', 'Second text'],
}),
})
const result = await res.json()
Response fields
The response comes in raw OpenAI format, without the success and data wrapper.
| Field | Type | Description |
|---|---|---|
Fieldobject |
Typestring | DescriptionAlways list |
Fielddata |
Typearray | DescriptionArray of vectors, one per input string |
Fielddata[].object |
Typestring | DescriptionAlways embedding |
Fielddata[].embedding |
Typenumber[] | DescriptionThe vector values. With encoding_format: base64, the vector arrives as a string |
Fielddata[].index |
Typenumber | DescriptionPosition of the string in the original input |
Fieldmodel |
Typestring | DescriptionThe model that processed the request |
Fieldusage.prompt_tokens |
Typenumber | DescriptionInput text tokens. Usage is calculated from them |
Fieldusage.completion_tokens |
Typenumber | DescriptionAlways 0 — embeddings produce no response tokens |
Fieldusage.total_tokens |
Typenumber | DescriptionEquals prompt_tokens |
Response example
The first three vector values are shown. The full dimensionality depends on the model — for bitrix/embeddings it is 4096 values, and the vector arrives normalized to unit length.
{
"object": "list",
"model": "bitrix/embeddings",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0203, 0.0034, -0.0156]
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 0,
"total_tokens": 12
}
}
Error response example
501 embeddings_unsupported — the model does not support embeddings:
{
"error": {
"message": "Model \"bitrix/bitrixgpt-5.5\" does not support embeddings.",
"type": "server_error",
"code": "embeddings_unsupported"
}
}
Errors
| HTTP | Code | Description |
|---|---|---|
| HTTP400 | Codeinvalid_request |
DescriptionInvalid parameters — empty input, malformed request body |
| HTTP400 | Codeinvalid_request |
DescriptionA dimensions value outside the 32…4096 range was passed for bitrix/embeddings. The response carries a param field set to dimensions. The request was not executed and nothing was charged |
| HTTP404 | Codeai_model_not_found |
DescriptionModel not found or disabled |
| HTTP501 | Codeembeddings_unsupported |
DescriptionThe model or provider does not support embeddings |
| HTTP402 | Codeai_credentials_not_configured |
DescriptionNo provider credentials for the model — connect your own key |
| HTTP402 | Codeinsufficient_balance |
DescriptionInsufficient funds for a paid model |
| HTTP402 | Codeai_quota_exhausted |
DescriptionThe portal's monthly AI quota is exhausted. The reason field distinguishes the case: breaker — the hourly over-quota spending breaker tripped, wallet_empty — the quota is exhausted and the portal balance has no funds, wallet_off — over-quota spend is not available for this portal. resetAt is the moment when requests will start passing again; it may be absent for wallet_off. In the wallet_empty case the response may additionally carry a hint string and a topupUrl link — see "Known specifics" below |
| HTTP402 | Codecompany_budget_exhausted |
DescriptionThe monthly company spend budget set by the portal administrator is exhausted. The scope field names the budget that was hit: USER — the caller's own budget, PORTAL — the budget of the whole portal. The canRequest field tells whether an increase can be requested: true for a personal budget, false for the portal one, which only an administrator raises. The rejection arrives only on calls that draw on the portal balance. Calls inside the plan quota and with your own provider key (BYOK) keep working |
| HTTP403 | Codescope_missing |
DescriptionThe API key is missing the vibe:ai scope |
| HTTP429 | Codeai_congested |
DescriptionThe AI cluster pool is overloaded. The request was not executed and nothing was charged — retry it after the delay in the Retry-After header. The response carries the X-AI-Admission: shed header, not X-RateLimit-Scope |
| HTTP400 | Codeai_provider_rejected |
DescriptionThe provider rejected the request itself (responded 400 or 422). Retrying it unchanged will not help |
| HTTP413 | Codeai_payload_too_large |
DescriptionThe provider rejected the request because the body is too large. The providerStatusCode field carries the original status 413. Retrying the same request returns the same response — send fewer or shorter texts |
| HTTP429 | Codeai_provider_cooldown |
DescriptionThe model cluster is temporarily unavailable and the platform backs off so retries do not pile up on it. The request was not executed and nothing was charged — retry it after the number of seconds in Retry-After. This response carries neither X-RateLimit-Scope nor X-AI-Admission |
| HTTP502 | Codeai_provider_unavailable |
DescriptionThe external provider answered with an error (401/403/5xx). The original status arrives in the providerStatusCode field when the provider answered the request with an HTTP status; if processing the provider's response fails (for example, a vector shorter than the requested dimensions), the field is absent |
| HTTP502 | Codeai_provider_network |
DescriptionThe platform could not connect to the provider, or the connection dropped before a response. This response carries no providerStatusCode: the provider never answered. Retry the request |
| HTTP429 | Codeai_pacing_limited |
DescriptionA daily or weekly quota pacing window is exceeded. This is not quota exhaustion — retry the request after the delay in the Retry-After header. See Pacing (day/week smoothing) |
The full list of common API errors — Errors.
Known specifics
Error codes come in lowercase. Most error bodies use the raw OpenAI format { "error": { "message", "type", "code" } }, without a success field. The 402 company_budget_exhausted rejection uses the same format — the scope and canRequest fields sit inside the same error object. Only quota and pacing rejections — 402 ai_quota_exhausted and 429 ai_pacing_limited — and an unexpected 5xx server error, whose code is written in uppercase, arrive in the { "success": false, "error": { … } } envelope. A handler must accept both envelopes.
The input array preserves order. The vector data[i] corresponds to the string input[i], and the data[].index field duplicates this position — you can use it to match the result after parallel processing.
The processing budget for a request is about 850 seconds. Once the budget runs out, 503 ai_provider_timeout is returned. This response deliberately carries no Retry-After header: repeating the same request would hit the same budget. Split the input array into smaller parts.
Response latency is not guaranteed for either a single text or an input array. It can vary from call to call, and several requests with an input array sent in a row may respond progressively more slowly. The dimensions parameter does not affect response speed. Add a pause between such requests and do not rely on the input array in an interactive scenario.
The top-up hint in a 402 ai_quota_exhausted response. Only in the reason: "wallet_empty" case may the response additionally carry a hint string and a topupUrl link to top up the balance. Both fields appear when enforced quota control and the top-up hint are enabled on the platform, so treat them as optional. The hint field in this response is a string. When the Bitrix24 account has no paid AI access, a reason: "wallet_off" response additionally carries details.learnMoreUrl — a page that describes the paid Bitrix24 plan that includes AI — and the message field names that plan. For other wallet_off causes details.learnMoreUrl is absent.
Usage is calculated from input tokens only. The usage.completion_tokens field is always 0, so you pay only for the input. The current input price of every model comes from GET /v1/models — read it there rather than from a fixed number in the documentation.
The dimensionality can be reduced. The bitrix/embeddings model is built so that the meaningful part of a vector is concentrated at its start: keeping the first k values and re-normalizing the vector to unit length left the ordering of search results unchanged in our tests, down to the smallest dimensions. This is a property of the model rather than a platform guarantee — measure it on your own data. The dimensions parameter does this on the platform side; you can get the same result yourself by truncating the vector and dividing every value by the length of the truncated vector. Re-normalizing is mandatory: a raw truncated vector has a length below one (for a 256-value vector the length is about 0.26), and without that step the dot product no longer matches cosine similarity and comparisons against previously stored vectors drift.
Sensible values are 256, 512, 1024, and 2048; these are reference points rather than the only accepted ones — any integer from 32 to 4096 works, including 1536 and 2000. The shorter the vector, the smaller the margin between a relevant result and a semantically close competitor, so choose the dimensionality by measuring on your own data.
A smaller dimensionality does not make a request cheaper or faster. The model still computes the full vector and the platform truncates it in the response: input-token usage and processing time do not change. The savings are on your side — less index storage, less memory, and faster search.
Vectors of different dimensionality must not be mixed in one similarity index. A 256-value and a 1024-value vector live in different spaces, and distances between them are meaningless. If you change the dimensionality, rebuild the entire index.