OpenAI Embeddings
文本向量化接口将文本转换为高维向量表示,用于语义搜索、文本分类、聚类等场景。
接口地址
| 方法 | 端点 |
|---|---|
| POST | https://neolink.com/api/v1/embeddings |
认证
| 方式 | 说明 |
|---|---|
| Bearer Token | 在请求头中携带 Authorization: Bearer <API_key> 用于验证账户信息。 |
请求头
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
Content-Type | string | 是 | 请求体的媒介类型,请设置为 application/json |
Authorization | string | 是 | Bearer API_key,用于验证账户信息 |
请求体
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
model | string | 是 | - | 使用的模型 ID |
input | string 或 array | 是 | - | 要转换为向量的输入文本。可以是单个字符串,或字符串数组(批量处理) |
encoding_format | string | 否 | float | 返回向量的编码格式。可选值:float 或 base64 |
dimensions | int | 否 | - | 返回向量的维度数。仅部分模型支持 |
user | string | 否 | - | 最终用户的唯一标识符,用于监控和检测滥用行为 |
请求示例
bash
curl --location --request POST 'https://neolink.com/api/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API Key>' \
--data-raw '{
"model": "<Model ID>",
"input": "什么是人工智能"
}'python
import requests
url = "https://neolink.com/api/v1/embeddings"
headers = {
"Authorization": "Bearer <API Key>"
}
files = {
"model": (None, "<Model ID>"),
"input": (None, "什么是人工智能"),
}
response = requests.post(url, headers=headers, files=files)
print(response.status_code)
print(response.text)支持模型Id:
- text-embedding-3-large
- text-embedding-3-small
- text-embedding-ada-002
- text-embedding-v4
