API reference
Embeddings API
Parameters, request and response examples for POST /v1/embeddings — turn text into vectors for semantic search, knowledge-base RAG, similar-question matching and deduplication. Same format as OpenAI Embeddings. Verified on this site.
POST /v1/embeddings turns one or more pieces of text into vectors — arrays of floating-point numbers. The closer two texts are in meaning, the closer their vectors, which is why embeddings power knowledge-base search, similar-question matching, clustering and deduplication. The format matches the OpenAI Embeddings API, and we have verified this endpoint on this site.
https://open.tutujin.com/v1/embeddingsHeaders
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk-..., an API key from the console |
Content-Type | Yes | application/json |
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name, e.g. text-embedding-3-small |
input | string or array | Yes | Text to embed. Pass an array of strings to embed several at once. Each piece has a length limit, so split long documents first |
encoding_format | string | No | float (default) returns float arrays; base64 returns a compact encoding that is smaller on the wire |
dimensions | integer | No | Output dimensions; text-embedding-3 models only. Fewer dimensions mean shorter vectors and cheaper storage and search |
user | string | No | Your end-user identifier, useful when investigating abuse |
Request example
curl https://open.tutujin.com/v1/embeddings \
-H "Authorization: Bearer $TUTUJIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": ["What is the return policy?", "How soon do orders ship?"]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://open.tutujin.com/v1", api_key=os.environ["TUTUJIN_API_KEY"])
resp = client.embeddings.create(
model="text-embedding-3-small",
input=["What is the return policy?", "How soon do orders ship?"],
)
vectors = [d.embedding for d in sorted(resp.data, key=lambda d: d.index)]
print(len(vectors), len(vectors[0]), resp.usage)import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://open.tutujin.com/v1', apiKey: process.env.TUTUJIN_API_KEY })
const resp = await client.embeddings.create({
model: 'text-embedding-3-small',
input: ['What is the return policy?', 'How soon do orders ship?'],
})
const vectors = [...resp.data].sort((a, b) => a.index - b.index).map((d) => d.embedding)
console.log(vectors.length, vectors[0].length, resp.usage)Compare two texts with cosine similarity. For small data sets compute it in memory; at scale, use a vector database such as pgvector, Milvus or Qdrant:
import math
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
return dot / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b)))
print(cosine(vectors[0], vectors[1]))Response example
{
"object": "list",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] },
{ "object": "embedding", "index": 1, "embedding": [0.0234, -0.0112, 0.0567] }
],
"model": "text-embedding-3-small",
"usage": { "prompt_tokens": 18, "total_tokens": 18 }
}The vectors above are cut to their first 3 numbers; real vectors are as long as the model's output dimensions.
| Field | Description |
|---|---|
data[].embedding | The vector, a float array (a string when encoding_format is base64) |
data[].index | Which item of input it belongs to; use it to match results to your text |
usage.prompt_tokens | Input tokens. Embedding models bill on these; there are no output tokens |
Notes
- Index and query a knowledge base with the same embedding model. After switching models, every stored vector has to be regenerated.
- Send several texts per request where you can; it saves round trips. Keep each request moderate — tens to a few hundred texts — so a retry stays cheap.
- Match results by
indexrather than assuming they come back in input order. - Most embedding models bill by input tokens and a few per request; the price table below and the Usage page in the console are the reference.
- For knowledge-base search, add a Rerank step after vector retrieval; the full setup is in Enterprise knowledge base and RAG.
Models that support this endpoint
| Model | Vendor | Cheapest group | Input ¥/1M | Output ¥/1M | Per request ¥ |
|---|---|---|---|---|---|
| text-embedding-3-large | OpenAI | Standard | ¥0.26 | ¥0.26 | — |
| qwen3-embedding-4b | Qwen | China Models | — | — | ¥0.0014 |
| qwen3-embedding-8b | Qwen | China Models | — | — | ¥0.0014 |
| qwen3-embedding-0.6b | Qwen | China Models | — | — | ¥0.0014 |
| qwen3-reranker-4b | Qwen | Standard | — | — | ¥0.002 |
| qwen3-reranker-0.6b | Qwen | Standard | — | — | ¥0.002 |
| qwen3-reranker-8b | Qwen | China Models | ¥0.00308 | ¥0.00308 | — |
| text-embedding-3-small | OpenAI | Standard | ¥0.04 | ¥0.04 | — |
Prices in CNY, cheapest group for each model; updated Nov 12, 2026, 8:17 PM.
18 models support this endpoint; the table shows some of them. See them all in the model hub
Still stuck? Add our WeChat support JsnonoChat and send the request id from the error message, and we will look into it.