POST /v1/embeddings
Use a configured business API model to build a searchable vector index.
No current prepared translation is available. The English source is shown without machine translation.
For a business integration, embeddings provide a way to search an internal knowledge base, match product descriptions or group related documents by meaning. The API returns numeric vectors for your application to store and compare. A retrieval-augmented generation (RAG) workflow can select relevant documents from that index and pass them to a separate text-generation request. Creating an embedding does not itself produce a conversational answer or store an index in the service.
Choose a model
Select an enabled model from Embeddings / vectors in the catalog available to your business account and API key. Its configuration must include the embeddings endpoint, an actual upstream route and an applicable input-token price. A model used successfully for chat is not evidence of vector support. When your integration uses an alias, the service resolves it before checking the endpoint, choosing the route and accounting for the request.
embedding-model below is a placeholder. Replace it with the exact model ID or enabled alias from your own catalog; the release does not add or activate provider models automatically.
Request
curl https://api.b2b-llm.com/v1/embeddings \
-H "Authorization: Bearer $B2B_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "embedding-model",
"input": ["First text", "Second text"],
"encoding_format": "float"
}'
| Field | Meaning |
|---|---|
model | Required model ID or enabled alias with explicit embeddings support. |
input | A nonempty string, a nonempty list of nonempty strings, a list of nonnegative integer token IDs, or a nonempty list of nonempty token-ID lists. Do not mix these forms. Token IDs must match the selected provider's tokenizer. |
encoding_format | Optional float or base64, if supported by the selected provider. The example explicitly requests numeric arrays. |
dimensions | Optional positive integer, only when the selected model supports changing its vector size. |
B2B LLM validates the input structure and forwards the chosen model's request without silently truncating text, estimating usage or substituting another model. The provider determines the token limit, batch size and available dimensions. Use the normal JSON request/response exchange: this endpoint does not support stream: true or native async: true. The separate Files/Batch interface can execute supported embedding items.
Response
This is a synthetic, shortened example. The numbers and token count are illustrative.
{
"object": "list",
"model": "embedding-model",
"data": [
{"object": "embedding", "index": 0, "embedding": [0.012, -0.044]},
{"object": "embedding", "index": 1, "embedding": [0.031, 0.009]}
],
"usage": {"prompt_tokens": 6, "total_tokens": 6}
}
Use index to associate each vector with its input and store the full returned vector. Keep the embedding model and dimensions consistent for indexed material and search queries. Rebuild the index when changing to an incompatible model or dimension.
Errors
If a business integration selects a model without the required endpoint capability, the gateway stops before the provider request and returns HTTP 400. The response has this OpenAI-compatible envelope:
{
"error": {
"code": "model_endpoint_not_supported",
"message": "The selected model is not enabled for this endpoint.",
"type": "invalid_request_error"
}
}
| Gateway code | What to correct |
|---|---|
model_endpoint_not_supported | Select a model explicitly configured to support this endpoint. A chat endpoint flag does not grant embeddings support. |
invalid_embeddings_input | Supply one supported, nonempty input form; do not mix text and token-ID forms. |
invalid_dimensions | Use a positive integer. Whether a valid dimension is available remains the selected provider's constraint. |
invalid_encoding_format | Use float or base64. |
embeddings_stream_not_supported | Remove stream: true and use the single JSON response. |
async_not_supported | Remove async: true; use the separate supported batch interface when appropriate. |
invalid_async_stream_combination | Do not request native async and streaming together. |
These validation failures use HTTP 400 with type invalid_request_error. Correct the request instead of automatically repeating it. Keep X-Request-ID for diagnostics. Provider error bodies and codes are not promised to match this example; authentication, account limits and sanitized upstream failures follow the general errors reference.
Usage and verification
Reconcile the request against the tariff applicable to your business account and the provider's actual input-token usage. Vector coordinates do not create output/completion tokens. If the response includes total_tokens, it must agree with the explicit input count; the total counter is optional. Missing or contradictory counters require review and do not establish free successful usage. The service does not infer token counts from text length or vector dimensions. Existing API-key, group and access restrictions continue to apply.
For administrators: save the model with Embeddings / vectors selected under configured endpoints, add the intended route and input-token price, and then explicitly run OpenAI Embeddings → Embeddings / vectors in capability verification. For a dedicated embedding model, leave the text endpoints unchecked. Saving does not run a probe. The manual probe makes one billable request with two short inputs, checks finite vectors and complete indices, and separately checks provider-reported input usage. A verified probe establishes that response contract, not semantic quality or provider identity; it does not enable a disabled model.
The manual verification probe accepts JSON responses up to 256 KiB and rejects duplicate JSON keys. A larger response is inconclusive for this bounded probe; this does not set the public API vector-size limit. No automatic repeat request is made.