跳到主要内容

Embeddings

POST /v1/embeddings turns text into vectors for semantic search, clustering and deduplication. It follows OpenAI's Embeddings API, so the OpenAI SDKs, and most frameworks built on them, work by changing the base URL.

Model: vectorize-io/vectorize-embedding-base-112m-multilingual-001

Dimensions384 by default; 256, 128 or 64 on request
Languages8, including English
Max input length8,192 tokens (longer inputs are truncated)
VectorsNormalized to unit length

Quick Start​

curl https://inference.hindsight.vectorize.io/v1/embeddings \
-H "Authorization: Bearer $HINDSIGHT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "vectorize-io/vectorize-embedding-base-112m-multilingual-001",
"input": ["Paris is the capital of France."]
}'

Request​

FieldTypeRequiredDescription
inputstring or array of stringsYesUp to 128 non-empty strings per request
modelstringNoThe model ID above (the default)
dimensionsintegerNo384 (default), 256, 128 or 64. See Shorter Vectors
encoding_formatstringNofloat (default) or base64

Token-array inputs are not supported; send text.

Response​

{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, …] }
],
"model": "vectorize-io/vectorize-embedding-base-112m-multilingual-001",
"usage": { "prompt_tokens": 8, "total_tokens": 8 }
}

data is in the same order as input, and each item's index says which input it belongs to. With encoding_format: "base64", each embedding is a base64 string of little-endian float32 values. The OpenAI Python SDK requests and decodes this format automatically.

Shorter Vectors​

The model is trained so that the first 256, 128 or 64 dimensions of its vector are themselves a usable embedding (Matryoshka representation learning). Shorter vectors cut storage and search cost at a small loss in quality.

Pass dimensions to get a shorter vector, re-normalized to unit length. Other sizes return 400. Use the same size for your documents and your queries.

Comparing Vectors​

Vectors are unit length, so cosine similarity and dot product give the same ranking. Embed queries and documents with the same model and the same dimensions.

For the best search quality, retrieve candidates by vector similarity, then rerank the top results.

Billing​

Embeddings cost $0.01 per 1M input tokens. usage.prompt_tokens reports exactly what was billed.