Embeddings

The key you use for chat also turns text into vectors (embeddings), from the same balance. Store the vectors, then find the texts closest to a question by comparing vectors: search over your documents, retrieval for a chat model (RAG), grouping, duplicates, recommendations.

One route, POST /v1/embeddings, the same request and reply as OpenAI's, so any OpenAI SDK or tool that takes a base URL works as it is.

Send a request

curl https://api.martllm.com/v1/embeddings \
  -H "Authorization: Bearer $MARTLLM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/text-embedding-3-small", "input": ["The first text to search", "The second text"]}'
from openai import OpenAI

client = OpenAI(base_url="https://api.martllm.com/v1", api_key="ull_your_key_here")

resp = client.embeddings.create(
    model="voyage/voyage-3.5",
    input=["The first text to search", "The second text"],
)
vectors = [d.embedding for d in resp.data]
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.martllm.com/v1", apiKey: process.env.MARTLLM_API_KEY });
const resp = await client.embeddings.create({ model: "qwen/qwen3-embedding-8b", input: "One text" });
console.log(resp.data[0].embedding.length);

The reply:

{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.0023, -0.0094, ...]},
    {"object": "embedding", "index": 1, "embedding": [0.0151, 0.0032, ...]}
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {"prompt_tokens": 12, "total_tokens": 12, "cost_usd": 0.0000002}
}

What you can send

Field What it is
model The model's id, e.g. openai/text-embedding-3-small. GET /v1/models?type=embedding lists every one on sale.
input A string, an array of strings (up to 2,048), or token ids. No empty strings.
encoding_format "float" (default) or "base64" (smaller replies for big batches).
dimensions Shorter vectors, on models that take it (OpenAI's text-embedding-3-*, among others).
user Your own id for the end user, passed on as it is.
metadata Your own tags, up to 16 short pairs, kept on your Activity row. Never sent to the model.

Each text must fit the model's own limit (its page and GET /v1/models/{id} show context_length, the most tokens one text may have).

What you pay

Embeddings are billed per input token, the same way a chat prompt is. There are no output tokens. Each model's page shows its price per 1M input tokens, and every reply carries what that call cost in usage.cost_usd. A call that fails costs nothing. Calls show on Activity like chat calls.

Models

GET /v1/models?type=embedding lists every embedding model you can call now, with its price. Among them: OpenAI text-embedding-3-small, text-embedding-3-large and text-embedding-ada-002; Voyage AI voyage-4, voyage-4-large, voyage-4-lite, voyage-3.5, voyage-3.5-lite, voyage-3-large, voyage-code-3, voyage-code-2, voyage-finance-2, voyage-law-2; Cohere embed-v4.0 and embed-v5.0; Google gemini-embedding-001, gemini-embedding-2, text-embedding-005, text-multilingual-embedding-002; Mistral mistral-embed and codestral-embed; Qwen3 Embedding 0.6B, 4B and 8B; Amazon Titan Text Embeddings V2; Perplexity pplx-embed; NVIDIA Llama Nemotron Embed VL; BGE-M3 and BGE-EN-ICL; multilingual E5 large instruct.

Vectors from different models cannot be compared with each other. Keep one model for everything you store and search together: MartLLM never answers an embeddings call with another model. If one route of the model cannot answer, the call goes to the next route of the same model.

Errors

The same error shapes as chat. The ones you may see here:

Code What to do
invalid_request Fix the field the message names (an empty text, more than 2,048 texts, a wrong encoding_format).
wrong_endpoint The model is not an embedding model; the message names the route it takes.
insufficient_credits Add credit; nothing was charged.
no_available_provider Nobody can serve the model right now. Try again shortly.

Reranking (/v1/rerank) and moderation (/v1/moderations) are not served.