Skip to content

Embeddings and reranking

Embeddings and reranking use different models. Copy the corresponding model name from the Pricing page.

POST /v1/embeddings
Authorization: Bearer OMROUTER_API_KEY
Content-Type: application/json
Terminal window
curl --silent --show-error \
'https://omrouter.com/v1/embeddings' \
--header "Authorization: Bearer $OMROUTER_API_KEY" \
--header 'Content-Type: application/json' \
--data "{
\"model\": \"$OMROUTER_MODEL_ID\",
\"input\": [\"First document\", \"Second document\"]
}"

The response contains one vector per input:

{
"object": "list",
"data": [
{"object": "embedding", "index": 0, "embedding": [0.0]}
],
"model": "model-id",
"usage": {}
}

Optional fields include encoding_format and dimensions where the selected model supports them.

POST /v1/rerank
Authorization: Bearer OMROUTER_API_KEY
Content-Type: application/json
Terminal window
curl --silent --show-error \
'https://omrouter.com/v1/rerank' \
--header "Authorization: Bearer $OMROUTER_API_KEY" \
--header 'Content-Type: application/json' \
--data "{
\"model\": \"$OMROUTER_MODEL_ID\",
\"query\": \"Which document explains authentication?\",
\"documents\": [
\"Use an API key in the Authorization header.\",
\"Video jobs are asynchronous.\"
],
\"top_n\": 1
}"
{
"results": [
{"index": 0, "relevance_score": 0.0}
],
"usage": {}
}

Set return_documents: true when the result should include the original text. Large document batches increase response time and cost, so split them according to the selected model’s limits.