Skip to main content
Embedding models convert text into dense vectors that represent semantic information, making semantically similar texts closer in vector space. They are commonly used for semantic search, retrieval, reranking, clustering, and RAG (Retrieval-Augmented Generation), and are served through an OpenAI-compatible Embeddings API. Representative models include:
  • Qwen/Qwen3-Embedding-8B
  • Qwen/Qwen3-Embedding-4B
  • Qwen/Qwen3-Embedding-0.6B
  • IEITYuan/Yuan-embedding-2.0-en
For the full model list and pricing, refer to Models.

Core Capabilities

  • Semantic search: Match queries and documents by meaning rather than exact keywords.
  • Retrieval for RAG: Embed knowledge base content and store the vectors, then retrieve the most relevant chunks to provide context for LLM answers.
  • Clustering and deduplication: Group similar items or detect near-duplicate content.
  • Recommendation and reranking: Score candidates by similarity to a query or user profile.

Usage

The Embeddings API accepts a single string or a list of strings and returns a vector for each input. Common workflow:
  1. Generate vectors for documents and store them.
  2. When a user sends a query, embed the query text.
  3. Compare the query vector with existing vectors, for example by using cosine similarity.

Key Parameters

  • model: The Embedding model name.
  • input: A string or a list of strings.
  • encoding_format: Accepted by some models, for example an encoding_format of float.

Notes

  • Use the same Embedding model for documents and queries so their vectors are in the same space and can be compared.
  • If an input exceeds the model’s maximum length, split the long text into smaller chunks before embedding. The maximum input length (context window), pricing, and supported languages vary by model and are shown in the model details in Models.
  • When embedding large amounts of text, batch multiple inputs into a single request to reduce round trips.

Billing

  • Formula: Total cost = input tokens x input unit price. Embedding model requests are billed only by input tokens and do not produce generated output.
  • Pricing: Check the model detail page in Models for each model’s pricing.
  • Recommendations:
    • Documents usually only need to be embedded once, and the results should be cached to avoid repeated computation on every request.
    • Prefer batch processing to improve request efficiency.

Examples

The examples read the API key from an environment variable to avoid writing secrets into code.

Embed Text (Python)

Embed Text (curl)

Semantic Similarity