Embeddings & Rerank

Used together they build RAG (retrieval-augmented generation) applications: embeddings turn text into vectors for semantic search, and rerank re-orders retrieved candidates by relevance.

Text Embeddings

Send text to /v1/embeddings and get vectors back. For available models and prices see the Model Plaza (look for names containing embedding); below we use text-embedding-v4.

FieldTypeRequiredNotes
modelstringYesEmbedding model name
inputstring or arrayYesText to vectorize; multiple items supported
cURL
Python (openai)
Node.js (openai)
curl https://api-model.shuntianchuang.cn/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-token" \
  -d '{
    "model": "text-embedding-v4",
    "input": ["What is an API gateway", "Shuntianchuang model service platform"]
  }'

Each entry in the returned data array contains an embedding (float vector) and an index; usage records billed tokens. Vectors are for storage (e.g. in a vector database) and retrieval — don't try to read them directly.

Rerank

Send a query plus candidate documents to /v1/rerank and get results sorted by relevance. For available models see the Model Plaza (look for names containing rerank); below we use qwen3-rerank.

FieldTypeRequiredNotes
modelstringYesRerank model name
querystringYesUser query
documentsarrayYesCandidate documents (array of strings)
top_nintegerNoReturn top N; defaults to all
cURL
Python
Node.js
curl https://api-model.shuntianchuang.cn/v1/rerank \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-token" \
  -d '{
    "model": "qwen3-rerank",
    "query": "How do I top up",
    "documents": [
      "If your balance is insufficient, top up on the billing platform. Alipay is supported.",
      "Create an API Key to start calling the API.",
      "The usage logs page shows the cost breakdown of every call."
    ],
    "top_n": 2
  }'

The returned results array is sorted by relevance in descending order; each entry contains an index (subscript into documents) and a relevance_score.