创建文本嵌入
POST /v1/embeddings
将文本转换为向量嵌入
基本信息
| 项目 | 内容 |
|---|---|
| Base URL | https://www.yunzhuhub.cn |
| 标签 | OpenAI格式(Embeddings) |
| Operation ID | createEmbedding |
认证
- BearerAuth:使用 Bearer Token 认证。 格式:
Authorization: Bearer sk-xxxxxx
密钥安全
请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。
参数
无额外路径或查询参数。
请求体
Content-Type: application/json
json
{
"title": "EmbeddingRequest",
"type": "object",
"required": [
"model",
"input"
],
"properties": {
"model": {
"type": "string",
"example": "<MODEL_ID>"
},
"input": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
],
"description": "要嵌入的文本"
},
"encoding_format": {
"type": "string",
"enum": [
"float",
"base64"
],
"default": "float"
},
"dimensions": {
"type": "integer",
"description": "输出向量维度"
}
}
}请求示例
以下示例只用于复制到本地终端,不会从文档站发送请求。
bash
curl --request POST 'https://www.yunzhuhub.cn/v1/embeddings' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '<REQUEST_JSON>'响应
200 成功创建嵌入
json
{
"title": "EmbeddingResponse",
"type": "object",
"properties": {
"object": {
"type": "string",
"example": "list"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"object": {
"type": "string",
"example": "embedding"
},
"index": {
"type": "integer"
},
"embedding": {
"type": "array",
"items": {
"type": "number"
}
}
}
}
},
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
}
}
}
}