Text embeddings
OpenAI-compatible embeddings for semantic search and RAG.
POST /v1/embeddings follows OpenAI semantics. Convert text into vectors for semantic search, RAG retrieval, clustering, and classification.
Basic request
from openai import OpenAI
client = OpenAI(
base_url="https://api.goodputai.cn/v1",
api_key="YOUR_GOODPUT_API_KEY",
)
resp = client.embeddings.create(
model="qwen/text-embedding-v4",
input="West Lake, Hangzhou",
)
print(len(resp.data[0].embedding)) # Vector dimensionsBatch input
Pass an array of strings as input. Each result’s index identifies its corresponding input:
resp = client.embeddings.create(
model="qwen/text-embedding-v4",
input=["First text passage", "Second text passage"],
)Parameters
| Parameter | Description |
|---|---|
model | Required; an embedding model ID from the catalog |
input | Required; a string or array of strings |
encoding_format | float (default) or base64 |
dimensions | Optional output dimensions, when supported; reducing dimensions can lower storage and retrieval costs |
Billing
Charged by input tokens (¥/million tokens), with no output charge. See current prices in the catalog and actual charges in request logs.
Use cosine similarity for embedding retrieval. Do not compare vectors from different models, or even from the same model with different dimensions.