Embeddings and reranking
Embeddings and reranking use different models. Copy the corresponding model name from the Pricing page.
Create embeddings
Section titled “Create embeddings”POST /v1/embeddingsAuthorization: Bearer OMROUTER_API_KEYContent-Type: application/jsoncurl --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.
Rerank documents
Section titled “Rerank documents”POST /v1/rerankAuthorization: Bearer OMROUTER_API_KEYContent-Type: application/jsoncurl --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.