POST /v1/embeddings converts text into vectors for semantic search, clustering, recommendations, and RAG retrieval.
Request
curl https://api.nbility.ai/v1/embeddings \
-H "Authorization: Bearer $NBILITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_EMBEDDING_MODEL",
"input": [
"An API gateway centralizes authentication, routing, and billing.",
"A vector database performs similarity search."
],
"encoding_format": "float"
}'
Fields
| Field | Type | Required | Description |
|---|---|---|---|
model | string | yes | Embedding model ID |
input | string | string[] | yes | One text or a batch of texts |
encoding_format | string | no | Commonly float; other formats are model-dependent |
dimensions | integer | no | Output dimensions; only some models support dimension reduction |
user | string | no | End-user identifier |
Items in data correspond to the input order:
{
"object": "list",
"data": [
{"object": "embedding", "index": 0, "embedding": [0.012, -0.034]}
],
"model": "YOUR_EMBEDDING_MODEL",
"usage": {"prompt_tokens": 8, "total_tokens": 8}
}
The example vector is truncated.
Operational guidance
- Index and query with the same model, dimensions, and normalization strategy.
- Batching reduces network overhead, but keep request size and texts per batch bounded.
- Vectors from different models are not directly comparable. Rebuild the index or use dual indexes during migration.
- Avoid logging source text that contains private data; redact it first when needed.