Skip to content

Embeddings

Use embeddings to convert text into vectors for search, retrieval, clustering, ranking, and similarity.

text
POST https://api.rout.my/v1/embeddings

Request

bash
curl https://api.rout.my/v1/embeddings \
  -H "Authorization: Bearer $ROUTMY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3-embedding-8b",
    "input": "The food was delicious and the service was excellent."
  }'

Request fields

FieldTypeRequiredNotes
modelstringYesExact embedding model ID from /v1/models.
inputstring, array of strings, token array, or batch token arraysYesText or token input to embed.
encoding_formatstringNofloat or base64, when supported by the upstream model.
dimensionsintegerNoRequested output dimension count, when supported by the model.
userstringNoAccepted for compatibility but stripped before upstream requests.

Extra fields are preserved for providers that support them.

Batch input

json
{
  "model": "qwen/qwen3-embedding-8b",
  "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="qwen/qwen3-embedding-8b",
    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": "qwen/qwen3-embedding-8b",
  "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_multiplier

Use /v1/models to inspect each model's token_multiplier.

API documentation for rout.my.