Skip to content
TutujinAPI

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.

POSThttps://www.tutujin.com/v1/embeddings

Headers

HeaderRequiredDescription
AuthorizationYesBearer sk-..., an API key from the console
Content-TypeYesapplication/json

Request body

ParameterTypeRequiredDescription
modelstringYesModel name, e.g. text-embedding-3-small
inputstring or arrayYesText to embed. Pass an array of strings to embed several at once. Each piece has a length limit, so split long documents first
encoding_formatstringNofloat (default) returns float arrays; base64 returns a compact encoding that is smaller on the wire
dimensionsintegerNoOutput dimensions; text-embedding-3 models only. Fewer dimensions mean shorter vectors and cheaper storage and search
userstringNoYour end-user identifier, useful when investigating abuse

Request example

curl https://www.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?"]
  }'

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:

Python
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

JSON
{
  "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.

FieldDescription
data[].embeddingThe vector, a float array (a string when encoding_format is base64)
data[].indexWhich item of input it belongs to; use it to match results to your text
usage.prompt_tokensInput 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 index rather 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 Logs 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

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
text-embedding-3-largeOpenAIStandard¥0.26¥0.26—
qwen3-embedding-4bQwenChina Models——¥0.0014
qwen3-embedding-0.6bQwenChina Models——¥0.0014
qwen3-embedding-8bQwenChina Models——¥0.0014
qwen3-reranker-0.6bQwenStandard——¥0.002
qwen3-reranker-4bQwenStandard——¥0.002
qwen3-reranker-8bQwenChina Models¥0.00308¥0.00308—
text-embedding-3-smallOpenAIStandard¥0.04¥0.04—

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 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.