Choose an embedding model
| Model | Default dimensions | Custom dimensions | Verified price |
|---|---|---|---|
text-embedding-3-large | 3,072 | Yes | $0.13 / 1M input tokens |
text-embedding-3-small | 1,536 | Yes | $0.02 / 1M input tokens |
text-embedding-ada-002 | 1,536 | No | $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 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
}'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]))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
| Field | Requirement | Notes |
|---|---|---|
model | Required | Use an exact model ID from the table |
input | Required | String, token array, or batch; no empty strings |
encoding_format | Optional | float or base64; default float |
dimensions | v3 only | Shortens vectors from text-embedding-3-large or text-embedding-3-small |
user | Optional | Stable 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
| Symptom | Fix |
|---|---|
| dimensions rejected | Use a text-embedding-3 model; ada-002 does not support it |
| Vector size mismatch | Set the database column/index to the returned dimension |
| Context length exceeded | Chunk the text below 8,192 tokens per input |
| Chat-style error | Use /v1/embeddings, not /v1/chat/completions |