DocsOpen Moon AI
Browse the docs

Embeddings

Reference for POST /v1/embeddings: turn texts into vectors in the OpenAI format, for semantic search or clustering, with Moon Blur applied to the text.

On this page

POST /v1/embeddings turns one or more texts into vectors of numbers. Two texts with similar meanings produce similar vectors: that is the basis of semantic search, document clustering and duplicate detection. The endpoint follows the OpenAI format, so the SDKs work unchanged.

HTTP
POST https://api.realmoon.ai/v1/embeddings
  • Authentication: an sk-moon-… key with the inference scope (see Authentication).
  • Body: JSON, 8 MB at most.
  • Response: a list object of vectors.

ParametersLink to the Parameters section

ParameterTypeRequiredDescription
modelstringyesAn embedding model from GET /v1/models?type=embedding.
inputstring, array of strings, or tokensyesThe text, or up to 2,048 texts. A list of integers (or a list of lists of integers) is read as pre-tokenized input. No empty strings.
dimensionsintegernoVector size, between 1 and the model’s size. Only for models that accept it (custom_dimensions set to true in /v1/models).
encoding_formatstringnofloat (default) or base64: the numbers as little-endian float32, base64-encoded.
input_typestringnoquery (a question) or document (a text to retrieve), for models that tell the two apart.
userstringnoYour end user’s identifier. Accepted, not passed on.

Any other parameter is rejected with 400 unknown_parameter.

ExampleLink to the Example section

cURL
curl https://api.realmoon.ai/v1/embeddings \
  -H "Authorization: Bearer $MOONAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistralai/mistral-embed-2312",
    "input": ["How do I cancel my contract?", "Store opening hours"]
  }'
Python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.realmoon.ai/v1", api_key=os.environ["MOONAI_API_KEY"])

result = client.embeddings.create(
    model="mistralai/mistral-embed-2312",
    input=["How do I cancel my contract?", "Store opening hours"],
)
for item in result.data:
    print(item.index, len(item.embedding))
JavaScript
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://api.realmoon.ai/v1', apiKey: process.env.MOONAI_API_KEY });

const result = await client.embeddings.create({
  model: 'mistralai/mistral-embed-2312',
  input: ['How do I cancel my contract?', 'Store opening hours'],
});
for (const item of result.data) console.log(item.index, item.embedding.length);

ResponseLink to the Response section

Response
{
  "object": "list",
  "model": "mistralai/mistral-embed-2312",
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] },
    { "object": "embedding", "index": 1, "embedding": [-0.0311, 0.0042, 0.0517] }
  ],
  "usage": { "prompt_tokens": 18, "total_tokens": 18, "credits": 1 }
}

The vectors are shortened in the example: a real vector from this model has 1,024 numbers.

FieldTypeDescription
objectstringAlways list.
modelstringThe model you called.
data[].objectstringAlways embedding.
data[].indexintegerThe text’s position in input.
data[].embeddingarray or stringThe vector: a list of numbers, or a base64 string with encoding_format: "base64".
usage.prompt_tokens, usage.total_tokensintegerTokens counted.
usage.creditsintegerCredits charged for the request.

Headers: X-Moon-Request-Id, X-Moon-Prompt-Storage: none, X-Moon-Blur and, when Moon Blur replaced values, X-Moon-Blur-Redactions.

Moon BlurLink to the Moon Blur section

When Moon Blur is on for the key (the default), the personal data it detects in the texts is replaced before sending to the model. Only the vectors of the affected passages change. The X-Moon-Blur header is on or off, and X-Moon-Blur-Redactions gives the number of values replaced. Text given as tokens is not read by Moon Blur. See Privacy.

ModelsLink to the Models section

List as of November 5, 2026; the current list, with prices and vector sizes, comes from GET /v1/models?type=embedding.

ModelVector sizedimensions
openai/text-embedding-3-small1,536yes
openai/text-embedding-3-large3,072yes
mistralai/mistral-embed-23121,024no
mistralai/codestral-embed-25051,536no
google/gemini-embedding-0013,072no
qwen/qwen3-embedding-8b4,096no
qwen/qwen3-embedding-4b2,560no
baai/bge-m31,024no
intfloat/multilingual-e5-large1,024no
voyageai/voyage-4, voyageai/voyage-4-lite, voyageai/voyage-code-4depends on the modelno
perplexity/pplx-embed-v1-4bdepends on the modelno

Use the same model for your documents and for your queries: vectors from two different models cannot be compared.

CostsLink to the Costs section

Before the call, the request holds the most the texts can count (one token per byte of text, plus a few tokens per text). It is then billed on the tokens actually counted, or on the actual cost reported by the provider. A request that fails costs nothing.

LimitsLink to the Limits section

LimitValue
Texts per request2,048
Request size8 MB, and about 1 million tokens
Response sizenumber of texts × vector size: 3 million numbers at most
Requests in flight per workspace8
Wait for the model’s response85 seconds at most

Beyond the response size, the API tells you how many texts this model accepts in one request: split them across several calls.

ErrorsLink to the Errors section

HTTPcodeMeaning
400missing_required_parametermodel is missing.
400unknown_parameterUnknown parameter.
400unsupported_parameterdimensions on a model that does not accept it, or a value the model rejects (with a hint).
400unsupported_valuedimensions out of range, or unknown encoding_format.
400nullMalformed, empty or oversized input, or too many texts (param: "input"); unknown input_type; invalid JSON body.
403org_policyYour organization’s rules refuse this model.
404model_not_foundUnknown model, or one that does not serve this endpoint.
413request_too_largeBody larger than 8 MB.
413moon_blur_payload_too_largeA text exceeds 500,000 characters, too long for Moon Blur: nothing is sent or charged.
429too_many_concurrentAlready 8 embedding requests in flight for this workspace.
429upstream_rate_limitedThe model is overloaded: retry after Retry-After (10 seconds).
502, 504upstream_error, upstream_timeoutThe model failed or did not respond in time.
503moon_blur_unavailableMoon Blur could not scan the texts: nothing is sent or charged.

Key, balance and spend cap errors are in Errors.

See alsoLink to the See also section

  • Models: the dimensions, custom_dimensions and context_length fields.
  • Privacy: what Moon Blur detects and does not detect.

Moon AI

Moon AI in action

0:00

Explore

Screenshots of chat.realmoon.ai taken on October 29, 2026, with fictional data.

Moon AI

Your preferences

Visits counted without cookies.

Our server counts visits without cookies or trackers. Your theme and your answer about ad measurement are remembered on this device.

Ad measurement

With your consent, our ad networks’ trackers (Google) measure our ads, from the visit to the sign-up and then to the first subscription and its amount, and may show you our ads. Your answer is valid for 13 months; you can change it here at any time.

No answer saved on this device.

After you decline, no tag is loaded anymore and the site deletes the cookies they had set on realmoon.ai. Those on the ad networks’ own domains are managed with them or in your browser.

The Moon AI app has its own privacy settings.