Embeddings
Convert text to vectors and keep models, dimensions, and indexes consistent.
Generate vectors
Choose an embedding model and set the key from the API overview. A general chat model is not a substitute for an embedding model.
curl --fail-with-body 'https://gateway.irouter.io/v1/embeddings' \
-H "Authorization: Bearer $IROUTER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"model":"<model-id>","input":["Account access","Payment receipt"]}'input can contain text or a text array where supported. Follow the target model's batch-size and input-length limits.
Store and retrieve
Response data contains embedding vectors. Use index to match their input order. Store text identifiers, model IDs, and vector dimensions together. Use consistent models and parameters for queries and indexed documents; changing models usually requires rebuilding the index.
Do not assume a universal dimension. Send dimensions only when the model supports it and configure the vector database accordingly.
Usage and errors
Embedding generation may incur charges. Check the model's catalog billing unit. Split oversized text into meaningful chunks; for unsupported models, revisit model selection. Track completed batch items to prevent duplicate indexing after network retries.