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

curl -X POST "https://api.siliconflow.cn/v1/embeddings" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "BAAI/bge-large-zh-v1.5",
    "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
  }'
const body = JSON.stringify({
  "model": "BAAI/bge-large-zh-v1.5",
  "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
})

fetch("https://api.siliconflow.cn/v1/embeddings", {
  body
})
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
  "strings"
)

func main() {
  url := "https://api.siliconflow.cn/v1/embeddings"
  body := strings.NewReader(`{
    "model": "BAAI/bge-large-zh-v1.5",
    "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
  }`)
  req, _ := http.NewRequest("POST", url, body)
  req.Header.Add("Content-Type", "application/json")
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.siliconflow.cn/v1/embeddings"
body = {
  "model": "BAAI/bge-large-zh-v1.5",
  "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
}
response = requests.request("POST", url, json = body, headers = {
  "Content-Type": "application/json"
})

print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;

var body = BodyPublishers.ofString("""{
  "model": "BAAI/bge-large-zh-v1.5",
  "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
}""");
HttpClient client = HttpClient.newBuilder()
  .connectTimeout(Duration.ofSeconds(10))
  .build();

HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
  .uri(URI.create("https://api.siliconflow.cn/v1/embeddings"))
  .header("Content-Type", "application/json")
  .POST(body)
  .build();

try {
  HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
  System.out.println("Status code: " + response.statusCode());
  System.out.println("Response body: " + response.body());
} catch (Exception e) {
  e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;

var body = new StringContent("""
{
  "model": "BAAI/bge-large-zh-v1.5",
  "input": "Silicon flow embedding online: fast, affordable, and high-quality embedding services. come try it out!"
}
""", Encoding.UTF8, "application/json");

var client = new HttpClient();
var response = await client.PostAsync("https://api.siliconflow.cn/v1/embeddings", body);
var responseBody = await response.Content.ReadAsStringAsync();
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"