We use cookies. Cookies and browser storage keep you signed in and remember your preferences. With your permission we also measure how the site is used. You can any time. See our cookie policy.

Embeddings

Endpoints

Embeddings

Create vector embeddings with POST /embeddings for semantic search, clustering, deduplication and retrieval augmented generation.

Try it in the playground

Turn text into vectors for semantic search, clustering, deduplication and retrieval-augmented generation (RAG). The endpoint has the same shape as OpenAI's POST /embeddings, so client.embeddings.create(...) works unchanged.

POST https://api14.com/api/v1/embeddings

Request

ParameterTypeRequiredDescription
modelstringyesAn embeddings model id, e.g. openai/text-embedding-3-small.
inputstring or string[]yesText to embed. Pass an array to embed many inputs in one request.
dimensionsintegernoOutput vector size, for models that support shortening (e.g. text-embedding-3-*).
encoding_formatstringnofloat (default) or base64.
userstringnoYour own end-user id, passed through upstream.
providerobjectnoProvider routing preferences. See Provider routing.

Example

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api14.com/api/v1",
  apiKey: process.env.API14_API_KEY,
});

const result = await client.embeddings.create({
  "model": "openai/text-embedding-3-small",
  "input": [
    "The quick brown fox",
    "Lorem ipsum"
  ]
});
console.log(result.data.map((d) => d.embedding.length));

Response

{
  "object": "list",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0023, -0.0091, 0.0154, "..."] }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": { "prompt_tokens": 8, "total_tokens": 8, "cost": 0.00000016 }
}

data[i].index matches the position of the input in your input array.

Choosing a model

List embeddings models with their prices, without an API key:

curl https://api14.com/api/v1/embeddings/models
# or, with categories and our prices:
curl "https://api14.com/api/v1/models?category=embeddings"

Vectors from different models are not comparable. Store the model id next to every vector and re-embed your corpus when you switch models.

Pricing

Embeddings are billed per input token at the model's listed price, shown as "$ / 1M tokens". The cost of each request is returned in usage.cost (USD) and debited from your balance. See Pricing & billing.

Tips

  • Batch inputs: one request with 100 strings is faster and counts as one request against your rate limit.
  • Keep each input under the model's context length; longer text is rejected upstream.
  • Normalize vectors (most models already return unit length) and use cosine similarity.

Errors

StatusCodeWhen
400model_required / invalid_jsonMissing model or the body is not a JSON object.
401invalid_api_keyMissing or invalid key.
402insufficient_balanceYour USD balance is $0.
403model_not_allowedThe key's model allowlist excludes this model.
404model_not_foundUnknown or disabled model id.
429rate_limitedRequests per minute exceeded.

Full list: Errors.