SiliconFlow
API手册

创建嵌入请求

将输入内容转换为嵌入向量。支持文本、图片 URL/base64 以及混合列表。

POST
/embeddings
AuthorizationBearer <token>required

添加 Header 'Authorization: Bearer {账户 API Key}' 进行鉴权

In: header

modelstringrequired

对应的模型名称。为更好地提升服务质量,我们会对本服务提供的模型进行定期变更,包括但不限于模型上下线和模型服务能力的调整。在可行的情况下,我们会通过公告或消息推送等适当方式通知您此类变更。完整可用模型列表请查看 Models

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

输入文本必须以字符串或字符串数组的形式提供。要在单次请求中处理多个输入,请传递字符串数组。输入长度不得超过模型的最大上下文 token 限制,且不应为空字符串。 各模型的最大输入 token 数如下:

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

"返回嵌入向量的格式。可选值:floatbase64"

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

输出嵌入向量的维度数。仅 Qwen/Qwen3 系列支持。 - 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

VL Embedding 的模型名称。支持模型:Qwen/Qwen3-VL-Embedding-8B。

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

待转换的输入内容。支持的形式:

  • 单个字符串
  • 内容对象(文本或图片)
  • 混合列表(字符串/内容对象)

注意:

  • 文本内容对象格式:{"text":"要嵌入的文本"}
  • 图片内容对象格式:{"image":"https://example.com/image.jpg"} 或 base64
  • 暂不支持视频内容
  • 输入长度不得超过模型的上下文限制,且不能为空

文本内容对象。

textstringrequired

待转换的文本内容。

Example"The quick brown fox"

图片内容对象。

imagestringrequired

图片 URL 或 base64 编码的图片内容。

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

内容列表,其中每个项目可以是字符串、文本对象或图片对象。

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

Item: 嵌入输入列表中的单个项目。

encoding_formatstring

输出编码格式。可选值:floatbase64

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

输出嵌入向量的维度数。仅 Qwen/Qwen3 系列支持。 - 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

用户标识符,用于请求追踪和速率限制。

Example"user_123"
truncatestring

超长文本的截断方向。可选值:left(左侧截断)或 right(右侧截断)

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

Response Body

模型响应。响应头中包含 x-siliconcloud-trace-id 字段,作为请求的唯一追踪标识,便于日志查询和问题排查。

TypeScript Definitions

Use the response body type in TypeScript.

objectstringrequired

对象类型,始终为 "list"。

Value in"list"
modelstringrequired

用于生成嵌入向量的模型名称。

dataarray<object>required

模型生成的嵌入向量列表。

usageobjectrequired

请求的使用信息。

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"