SiliconFlow

创建嵌入请求

Converts input content into embedding vectors. Supports text, image URL/base64, and mixed lists.

POST
/embeddings
AuthorizationBearer <token>required

Use the following format for authentication: Bearer

In: header

modelstringrequired

Corresponding Model Name. To better enhance service quality, we will make periodic changes to the models provided by this service, including but not limited to model on/offlining and adjustments to model service capabilities. We will notify you of such changes through appropriate means such as announcements or message pushes where feasible. For a complete list of available models, please check the Models.

Example"BAAI/bge-large-zh-v1.5"
inputstring | arrayrequired

Input text to embed must be provided as a string or an array of tokens. To process multiple inputs in a single request, pass an array of strings or an array of token arrays. The input length must not exceed the model's maximum token limit and should not be an empty string. The maximum input tokens for each model are as follows:

BAAI/bge-large-zh-v1.5, BAAI/bge-large-en-v1.5, netease-youdao/bce-embedding-base_v1: 512 BAAI/bge-m3, Pro/BAAI/bge-m3: 8192 Qwen/Qwen3-Embedding-8B, Qwen/Qwen3-Embedding-4B, Qwen/Qwen3-Embedding-0.6B: 32768

encoding_formatstring

"The format to return the embeddings in. Can be either float or base64"

Default"float"
Value in"float" | "base64"
Example"float"
dimensionsinteger

The number of dimensions the resulting output embeddings should have. Only supported in Qwen/Qwen3 series. - Qwen/Qwen3-Embedding-8B: [64,128,256,512,768,1024,1536,2048,2560,4096] - Qwen/Qwen3-Embedding-4B:[64,128,256,512,768,1024,1536,2048,2560] - Qwen/Qwen3-Embedding-0.6B: [64,128,256,512,768,1024]

Example1024
modelstringrequired

The model name for VL Embedding. support models:Qwen/Qwen3-VL-Embedding-8B.

Example"Qwen/Qwen3-VL-Embedding-8B"
inputstring | object | object | arrayrequired

Input content to be converted. Supported forms:

  • A single string
  • A content object (text or image)
  • A mixed list (strings/content objects)

Notes:

  • Text content object format: {"text":"text to embed"}
  • Image content object format: {"image":"https://example.com/image.jpg"} or base64
  • Video content is not supported yet
  • Input length must not exceed the model context limit and cannot be empty

Text content object.

textstringrequired

Text content to be converted.

Example"The quick brown fox"

Image content object.

imagestringrequired

Image URL or base64-encoded image content.

Example"https://example.com/image.jpg"

A content list where each item can be a string, text object, or image object.

Example["First text",{"text":"Second text"},{"image":"https://example.com/image.jpg"}]

Item: A single item in the embedding input list.

encoding_formatstring

Output encoding format. Available values: float or base64.

Default"float"
Value in"float" | "base64"
Example"float"
dimensionsinteger

The number of dimensions the resulting output embeddings should have. Only supported in Qwen/Qwen3 series. - Qwen/Qwen3-Embedding-8B: [64,128,256,512,768,1024,1536,2048,2560,4096] - Qwen/Qwen3-Embedding-4B:[64,128,256,512,768,1024,1536,2048,2560] - Qwen/Qwen3-Embedding-0.6B: [64,128,256,512,768,1024]

Example1024
userstring

User identifier for request tracing and rate limiting.

Example"user_123"
truncatestring

Truncation direction for overlong text. Available values: left or right.

Value in"left" | "right"
Example"right"

Response Body

The response from the model. The response header contains the x-siliconcloud-trace-id field, which serves as a unique identifier for tracing requests, facilitating log queries and issue troubleshooting.

TypeScript Definitions

Use the response body type in TypeScript.

objectstringrequired

The object type, which is always "list".

Value in"list"
modelstringrequired

The name of the model used to generate the embedding.

dataarray<object>required

The list of embeddings generated by the model.

usageobjectrequired

The usage information for the request.

curl -X POST https://api.siliconflow.cn/v1/embeddings \
  -H "Authorization: Bearer $SILICONFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Hello, world!",
    "model": "Qwen/Qwen3-VL-Embedding-8B"
  }'
import requests

response = requests.post(
    "https://api.siliconflow.cn/v1/embeddings",
    headers={
        "Authorization": "Bearer $SILICONFLOW_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "input": "Hello, world!",
        "model": "Qwen/Qwen3-VL-Embedding-8B"
    }
)
print(response.json())
fetch("https://api.siliconflow.cn/v1/embeddings", {
  method: "POST",
  headers: {
    "Authorization": "Bearer $SILICONFLOW_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    input: "Hello, world!",
    model: "Qwen/Qwen3-VL-Embedding-8B"
  })
})
.then(res => res.json())
.then(console.log);
curl -X POST https://api.siliconflow.cn/v1/embeddings \
  -H "Authorization: Bearer $SILICONFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "text": "The quick brown fox"
    },
    "model": "Qwen/Qwen3-VL-Embedding-8B",
    "encoding_format": "float"
  }'
import requests

response = requests.post(
    "https://api.siliconflow.cn/v1/embeddings",
    headers={
        "Authorization": "Bearer $SILICONFLOW_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "input": {
            "text": "The quick brown fox"
        },
        "model": "Qwen/Qwen3-VL-Embedding-8B",
        "encoding_format": "float"
    }
)
print(response.json())
fetch("https://api.siliconflow.cn/v1/embeddings", {
  method: "POST",
  headers: {
    "Authorization": "Bearer $SILICONFLOW_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    input: {
      text: "The quick brown fox"
    },
    model: "Qwen/Qwen3-VL-Embedding-8B",
    encoding_format: "float"
  })
})
.then(res => res.json())
.then(console.log);
curl -X POST https://api.siliconflow.cn/v1/embeddings \
  -H "Authorization: Bearer $SILICONFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "image": "https://example.com/image.jpg"
    },
    "model": "Qwen/Qwen3-VL-Embedding-8B"
  }'
import requests

response = requests.post(
    "https://api.siliconflow.cn/v1/embeddings",
    headers={
        "Authorization": "Bearer $SILICONFLOW_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "input": {
            "image": "https://example.com/image.jpg"
        },
        "model": "Qwen/Qwen3-VL-Embedding-8B"
    }
)
print(response.json())
fetch("https://api.siliconflow.cn/v1/embeddings", {
  method: "POST",
  headers: {
    "Authorization": "Bearer $SILICONFLOW_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    input: {
      image: "https://example.com/image.jpg"
    },
    model: "Qwen/Qwen3-VL-Embedding-8B"
  })
})
.then(res => res.json())
.then(console.log);
curl -X POST https://api.siliconflow.cn/v1/embeddings \
  -H "Authorization: Bearer $SILICONFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      "First text",
      {
        "text": "Second text"
      },
      {
        "image": "https://example.com/image.jpg"
      }
    ],
    "model": "Qwen/Qwen3-VL-Embedding-8B",
    "dimensions": 768
  }'
import requests

response = requests.post(
    "https://api.siliconflow.cn/v1/embeddings",
    headers={
        "Authorization": "Bearer $SILICONFLOW_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "input": [
            "First text",
            {
                "text": "Second text"
            },
            {
                "image": "https://example.com/image.jpg"
            }
        ],
        "model": "Qwen/Qwen3-VL-Embedding-8B",
        "dimensions": 768
    }
)
print(response.json())
fetch("https://api.siliconflow.cn/v1/embeddings", {
  method: "POST",
  headers: {
    "Authorization": "Bearer $SILICONFLOW_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    input: [
      "First text",
      {
        text: "Second text"
      },
      {
        image: "https://example.com/image.jpg"
      }
    ],
    model: "Qwen/Qwen3-VL-Embedding-8B",
    dimensions: 768
  })
})
.then(res => res.json())
.then(console.log);
curl -X POST https://api.siliconflow.cn/v1/embeddings \
  -H "Authorization: Bearer $SILICONFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Very long text content...",
    "model": "Qwen/Qwen3-VL-Embedding-8B",
    "truncate": "right",
    "user": "user_123"
  }'
import requests

response = requests.post(
    "https://api.siliconflow.cn/v1/embeddings",
    headers={
        "Authorization": "Bearer $SILICONFLOW_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "input": "Very long text content...",
        "model": "Qwen/Qwen3-VL-Embedding-8B",
        "truncate": "right",
        "user": "user_123"
    }
)
print(response.json())
fetch("https://api.siliconflow.cn/v1/embeddings", {
  method: "POST",
  headers: {
    "Authorization": "Bearer $SILICONFLOW_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    input: "Very long text content...",
    model: "Qwen/Qwen3-VL-Embedding-8B",
    truncate: "right",
    user: "user_123"
  })
})
.then(res => res.json())
.then(console.log);
{
  "object": "list",
  "model": "string",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0
      ],
      "index": 0
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
{
  "code": 20012,
  "message": "string",
  "data": "string"
}
"Invalid token"
"Forbidden"
"404 page not found"
{
  "message": "Request was rejected due to rate limiting. If you want more, please contact contact@siliconflow.cn. Details:TPM limit reached.",
  "data": "string"
}
{
  "code": 50505,
  "message": "Model service overloaded. Please try again later.",
  "data": "string"
}
"string"