Skip to main content
POST
/
v1
/
embeddings
创建嵌入
curl --request POST \
  --url https://api.qhaigc.net/v1/embeddings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "input": "<string>"
}
'
{
  "object": "<string>",
  "data": [
    {
      "embedding": [
        123
      ],
      "index": 123,
      "object": "<string>"
    }
  ],
  "model": "<string>",
  "usage": {}
}

功能说明

将输入的文本转换为向量(Embeddings),适用于语义搜索、推荐系统、分类和聚类等场景。

请求参数

名称类型必选说明
modelstring模型名称,如 bge-m3text-embedding-3-large
inputstring要转换为向量的文本内容

调用示例

import openai

client = openai.OpenAI(
    api_key="sk-your-api-key-here",
    base_url="https://api.qhaigc.net/v1"
)

response = client.embeddings.create(
    model="bge-m3",
    input="启航 AI API 系统是一款聚焦低成本探索 AIGC 无限可能的服务平台"
)

print(response.data[0].embedding)

返回结果

返回包含向量数据的对象。
{
  "object": "list",
  "data": [
    {
      "embedding": [
        -0.06332587,
        -0.019955011,
        -0.03361425,
        // ... 共 1024 或更多维度
      ],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "bge-m3",
  "usage": {
    "prompt_tokens": 21,
    "total_tokens": 21
  }
}

相关参考

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
string
required

模型名称

input
string
required

要转化的文本

Response

200 - application/json

成功响应

object
string
data
object[]
model
string
usage
object