跳转到主要内容
Use this endpoint to convert text into numerical vector representations (embeddings). You can then use these vectors for semantic search, retrieval-augmented generation (RAG), clustering, and classification — any task that benefits from measuring meaning-based similarity between texts. Endpoint: POST https://api.qhaigc.net/v1/embeddings

Supported Models

Model IDDimensionsMax TokensLanguages
bge-m310248192100+ languages
text-embedding-3-large30728192Multilingual
Use bge-m3 for multilingual content or when you need long-context support (up to 8192 tokens per input). Use text-embedding-3-large when you need higher-dimensional embeddings for maximum retrieval precision.

Request Parameters

model
string
必填
The embedding model to use. Examples: bge-m3, text-embedding-3-large.
input
string | array
必填
The text to embed. Pass a single string, or an array of strings to embed multiple texts in one request. Each string must be within the model’s token limit.
encoding_format
string
The format of the returned embeddings. Use "float" (default) for an array of 32-bit floats, or "base64" for a base64-encoded string.

Response Fields

object
string
Always "list".
data
array
Array of embedding objects, one per input string. Results are returned in the same order as the inputs.
model
string
The model that produced the embeddings.
usage
object
Token usage for this request.

Code Examples

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key-here",
    base_url="https://api.qhaigc.net/v1"
)

response = client.embeddings.create(
    model="bge-m3",
    input="Qhaigc is an AI API platform focused on low-cost exploration of AIGC capabilities."
)

embedding = response.data[0].embedding
print(f"Embedding dimensions: {len(embedding)}")
print(f"First 5 values: {embedding[:5]}")

Batch embedding multiple texts

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key-here",
    base_url="https://api.qhaigc.net/v1"
)

texts = [
    "Semantic search finds documents by meaning, not keywords.",
    "RAG combines retrieval with language model generation.",
    "Vector databases store embeddings for fast similarity search."
]

response = client.embeddings.create(model="bge-m3", input=texts)

for item in response.data:
    print(f"Text {item.index}: {len(item.embedding)}-dimensional vector")

Example Response

{
  "object": "list",
  "data": [
    {
      "embedding": [
        -0.06332587,
        -0.019955011,
        -0.03361425
      ],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "bge-m3",
  "usage": {
    "prompt_tokens": 21,
    "total_tokens": 21
  }
}

Common Use Cases

Build a RAG pipeline by embedding your knowledge base, storing vectors in a vector database, retrieving the top-k relevant chunks at query time, and passing them as context to a chat model.
Detect near-duplicate content or find semantically similar items in your dataset by comparing embedding vectors.
Use embeddings as features for downstream classifiers, or group semantically similar texts with k-means or hierarchical clustering.