The System One EventUtahGo To Event Page →

Docs

Set up Midium, use every part of it, run it for your team, and build on it.

Embeddings & rerank

POST /v1/embeddings turns text into vectors (OpenAI-compatible); POST /v1/rerank orders documents by relevance to a query (Cohere/Jina-compatible).

For developers

POST /v1/embeddings turns text into vectors for search, clustering or memory, in OpenAI's format. POST /v1/rerank scores a list of documents against a query with a cross-encoder and returns them best first, in Cohere's and Jina's format. Both need the right kind of model: install an embedding or reranker model from Settings → Catalog, or with midium models catalog --type embedding (--type rerank).

Embeddings request#

curl http://127.0.0.1:9100/v1/embeddings \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<your embedding model>",
    "input": ["The quick brown fox", "jumps over the lazy dog"]
  }'

Use the model's name from GET /v1/models (entries with type: "embedding").

Embeddings parameters#

NameTypeDescription
modelstringRequired. An embedding model's name or nickname.
inputstring or arrayRequired. A string or a list of strings. None may be empty.
encoding_formatstringfloat (default) or base64 — the vector as little-endian float32 bytes, base64-encoded.
dimensionsintegerShorten each vector to this many dimensions. It's renormalized after cutting. Must not exceed the model's size.
input_typestringMidium: query or search_query marks the input as a search query, so instruction-tuned embedders (Qwen3 Embedding) get their query instruction. Leave it out for documents.
userstringAccepted and ignored.

Embeddings response#

JSON
{
  "object": "list",
  "data": [
    {"object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789]},
    {"object": "embedding", "index": 1, "embedding": [0.0311, 0.0042, -0.0638]}
  ],
  "model": "<your embedding model>",
  "usage": {"prompt_tokens": 12, "total_tokens": 12}
}

Vectors are L2-normalized, so a dot product is the cosine similarity.

Rerank request#

curl http://127.0.0.1:9100/v1/rerank \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<your reranker model>",
    "query": "Which vendor sends our SMS alerts?",
    "documents": [
      "Twilio handles all outbound SMS for alerting.",
      "Invoices are emailed on the first of the month.",
      "PagerDuty pages the on-call engineer."
    ],
    "top_n": 2,
    "return_documents": true
  }'

Rerank parameters#

NameTypeDescription
modelstringRequired. A reranker model's name (type: "rerank" in GET /v1/models).
querystringRequired. Not empty.
documentsarray of stringsRequired. None may be empty.
top_nintegerReturn only the best n. Default: all.
return_documentsbooleanInclude each document's text in the results. Default false.

Rerank response#

JSON
{
  "object": "list",
  "results": [
    {"index": 0, "relevance_score": 0.982, "document": {"text": "Twilio handles all outbound SMS for alerting."}},
    {"index": 2, "relevance_score": 0.041, "document": {"text": "PagerDuty pages the on-call engineer."}}
  ],
  "model": "<your reranker model>",
  "usage": {"total_tokens": 0}
}

results are sorted best first; index points into your documents. Scores run from 0 to 1 (higher is more relevant). usage.total_tokens is always 0.

Errors#

StatuscodeWhen
404model_not_foundNo model by that name. The message lists the models you can use.
400unsupported_model_typeThe model isn't an embedding model (embeddings) or a reranker (rerank).
422—Empty input, query or documents, an empty string in a list, or dimensions / top_n below 1.
500embedding_error / rerank_errorThe model failed, for example dimensions larger than the model's vectors.

See Errors & limits.

Something here wrong or out of date? Tell us.