Create Embeddings
Embed text in OpenRouter's embeddings shape, which is OpenAI's with input_type and an id added.
Batches: Up to 2048 inputs per request. The API splits them into batches the model's engine accepts and returns the embeddings in input order.
Queries and documents: Instruction-aware models such as qwen3-embedding-4b retrieve better when queries carry an instruction. Set input_type to search_query on queries and the model's instruction is prepended; documents (search_document, or no input_type) are sent unchanged. A query that already starts with the instruction's marker (e.g. Instruct:) is not prefixed again. The prefix's tokens are billed.
Long inputs: An input longer than the model's maximum input length is truncated to it, not rejected.
Body
application/jsonOpenRouter's embeddings request. OpenRouter's provider, session_id and trace and OpenAI's user are accepted and ignored.
-
model string required
The embeddings model to use.
-
input string or array of strings or array of integers or array of array of integers required
A string, a list of strings, a list of token ids, or a list of token id lists. Up to 2048 inputs. Multimodal inputs are rejected.
-
encoding_format string
base64returns each embedding as base64-encoded little-endian float32 values.default floatfloatbase64 -
dimensions integer
Truncate embeddings to this many dimensions, for models trained to support it (e.g. Qwen3-Embedding).
at least 1 -
input_type string
search_query(orquery) marks the inputs as search queries, so instruction-aware models get their query instruction. Any other value, or none, sends the inputs unchanged.
Responses
OK
application/json · embeddings-response-payload
The request body is not a JSON object, the model rejected the request, or an input is longer than the model's context length (metadata.error_type context_)
application/json · error-payload
The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>.
application/json · error-payload
Model not found
application/json · error-payload
Rate limit exceeded
application/json · error-payload
The model could not be reached or returned an unusable response
application/json · error-payload
The model timed out
application/json · error-payload
The request body is over 16 MB
application/json · error-payload
curl https://api.vultrinference.com/v1/embeddings \
-H "Authorization: Bearer $VULTR_INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-embedding-4b",
"input": [
"What is the capital of France?"
],
"input_type": "search_query"
}'import os
import requests
response = requests.post(
"https://api.vultrinference.com/v1/embeddings",
headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
json={
"model": "qwen3-embedding-4b",
"input": [
"What is the capital of France?",
],
"input_type": "search_query",
},
)
print(response.json())const response = await fetch("https://api.vultrinference.com/v1/embeddings", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "qwen3-embedding-4b",
"input": [
"What is the capital of France?"
],
"input_type": "search_query"
}),
});
console.log(await response.json());{
"id": "string",
"object": "string",
"data": [
{
"object": "string",
"index": 0,
"embedding": [
null
]
}
],
"model": "string",
"usage": {
"prompt_tokens": 0,
"total_tokens": 0
}
}