Legacy Embeddings 兼容路径
curl --request POST \
--url https://kaienapi.com/v1/engines/{model}/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "需要向量化的文本"
}
'import requests
url = "https://kaienapi.com/v1/engines/{model}/embeddings"
payload = { "input": "需要向量化的文本" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({input: '需要向量化的文本'})
};
fetch('https://kaienapi.com/v1/engines/{model}/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/engines/{model}/embeddings"
payload := strings.NewReader("{\n \"input\": \"需要向量化的文本\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"object": "list",
"data": [
{}
],
"model": "<string>",
"usage": {}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Legacy Embeddings 兼容路径
兼容旧版 OpenAI 风格的 embeddings 路径,行为与 /v1/embeddings 一致。
迁移说明
新接入优先使用 /v1/embeddings。保留本路径是为了兼容仍把模型名放在 URL 中的旧 SDK 或旧代码。请求体仍需传入 input。旧代码迁移时,把 URL 中的 {model} 移到请求体的 model 字段。
POST
/
v1
/
engines
/
{model}
/
embeddings
Legacy Embeddings 兼容路径
curl --request POST \
--url https://kaienapi.com/v1/engines/{model}/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "需要向量化的文本"
}
'import requests
url = "https://kaienapi.com/v1/engines/{model}/embeddings"
payload = { "input": "需要向量化的文本" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({input: '需要向量化的文本'})
};
fetch('https://kaienapi.com/v1/engines/{model}/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/engines/{model}/embeddings"
payload := strings.NewReader("{\n \"input\": \"需要向量化的文本\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"object": "list",
"data": [
{}
],
"model": "<string>",
"usage": {}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}⌘I