VECTOR OUTPUT

Embeddings API

Convert one string or a batch of strings into vectors for semantic search, retrieval, recommendations and clustering.

3 modelsBatch input verifiedFloat and base64

Choose an embedding model

ModelDefault dimensionsCustom dimensionsVerified price
text-embedding-3-large3,072Yes$0.13 / 1M input tokens
text-embedding-3-small1,536Yes$0.02 / 1M input tokens
text-embedding-ada-0021,536No$0.10 / 1M input tokens

Use text-embedding-3-small for the lowest cost, or text-embedding-3-large when retrieval quality matters more. Keep one model and one vector size within an existing index.

Create embeddings

input accepts a string or an array. The array order is preserved in data[].index.

cURL · batch with reduced dimensions
curl https://api-models.com/v1/embeddings \
  -H "Authorization: Bearer $API_MODELS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": ["First document", "Second document"],
    "encoding_format": "float",
    "dimensions": 256
  }'
Python · requests
import os
import requests

response = requests.post(
    "https://api-models.com/v1/embeddings",
    headers={
        "Authorization": f"Bearer {os.environ['API_MODELS_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "text-embedding-3-large",
        "input": ["First document", "Second document"],
        "encoding_format": "float",
        "dimensions": 1024,
    },
    timeout=120,
)
response.raise_for_status()
vectors = [item["embedding"] for item in response.json()["data"]]
print(len(vectors), len(vectors[0]))
Node.js · fetch
const response = await fetch("https://api-models.com/v1/embeddings", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.API_MODELS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "text-embedding-3-small",
    input: ["First document", "Second document"],
    encoding_format: "float",
    dimensions: 256,
  }),
});
if (!response.ok) throw new Error(await response.text());
const result = await response.json();
console.log(result.data.map((item) => item.embedding.length));

Parameters and limits

FieldRequirementNotes
modelRequiredUse an exact model ID from the table
inputRequiredString, token array, or batch; no empty strings
encoding_formatOptionalfloat or base64; default float
dimensionsv3 onlyShortens vectors from text-embedding-3-large or text-embedding-3-small
userOptionalStable end-user identifier for abuse monitoring

Each input is limited to 8,192 tokens. A request can contain up to 2,048 inputs, with no more than 300,000 total input tokens across the request.

Store and compare vectors correctly

  • Persist the model ID and dimensions with every index version.
  • Use the same embedding model for stored documents and search queries.
  • Normalize or choose a distance metric supported by your vector database.
  • Rebuild the index when you change model or dimensions; vectors from different spaces are not interchangeable.

Common errors

SymptomFix
dimensions rejectedUse a text-embedding-3 model; ada-002 does not support it
Vector size mismatchSet the database column/index to the returned dimension
Context length exceededChunk the text below 8,192 tokens per input
Chat-style errorUse /v1/embeddings, not /v1/chat/completions