cheapinference.dev
API REFERENCE

Embeddings

Text vectors, dimensions, encoding, and token usage.

Create text embeddings

POST /embeddings

Embeddings turn text into vectors for similarity search, clustering, and retrieval. Use a text embedding model from the catalog; chat models cannot be used on this endpoint.

import OpenAI from "openai";
const client = new OpenAI({
  baseURL: "https://www.cheapinference.dev/v1",
  apiKey: process.env.CHEAPINFERENCE_API_KEY,
});

const result = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: ["A small change.", "A better bottom line."],
  dimensions: 256, encoding_format: "float",
});
for (const item of result.data) console.log(item.index, item.embedding);

Input and encoding

FieldBehavior
inputString, array of strings, token-ID array, or array of token-ID arrays
dimensionsPositive integer; only models supporting reduced dimensions accept it
encoding_formatfloat (numeric vectors) or base64 (encoded output)
userOptional end-user identifier

Use each item’s index to map the returned vector to its input. Keep the same model and dimensions for stored vectors and search queries. Batch related inputs within the model’s input limits and the public 4 MB request limit. OpenAI rejects empty or otherwise invalid input.

Usage and limits

Embedding responses contain usage.prompt_tokens and usage.total_tokens; there is no generated-output charge. Requests are not streamed. This service exposes OpenAI text embedding models, not image embedding models from other providers.

Discover IDs with client.models.list() or the catalog. The official SDK already decodes the response—you do not need another client library.