Embeddings
Use embeddings to convert text into vectors for search, retrieval, clustering, ranking, and similarity.
text
POST https://api.rout.my/v1/embeddingsRequest
bash
curl https://api.rout.my/v1/embeddings \
-H "Authorization: Bearer $ROUTMY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "provider/embedding-model-id",
"input": "The food was delicious and the service was excellent."
}'Request fields
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | Exact embedding model ID from /v1/models. |
input | string, array of strings, token array, or batch token arrays | Yes | Text or token input to embed. |
encoding_format | string | No | float or base64, when supported by the upstream model. |
dimensions | integer | No | Requested output dimension count, when supported by the model. |
user | string | No | Client-side user identifier. |
Extra fields are preserved for providers that support them.
Batch input
json
{
"model": "provider/embedding-model-id",
"input": [
"First document.",
"Second document.",
"Third document."
]
}The response preserves input order through the index field.
Python
python
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.rout.my/v1",
api_key=os.environ["ROUTMY_API_KEY"],
)
response = client.embeddings.create(
model="provider/embedding-model-id",
input=["First document.", "Second document."],
)
for item in response.data:
print(item.index, len(item.embedding))Response
json
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0093, 0.0142]
}
],
"model": "provider/embedding-model-id",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5
}
}Quota accounting
Embedding requests count prompt tokens only. The final quota usage is:
text
input tokens x token_multiplierUse /v1/models to inspect each model's token_multiplier.