Create embeddings
curl --request POST \
--url https://api.maxapi.ai/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
'import requests
url = "https://api.maxapi.ai/v1/embeddings"
payload = {
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'text-embedding-ada-002',
input: 'The food was delicious and the waiter...'
})
};
fetch('https://api.maxapi.ai/v1/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://api.maxapi.ai/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/v1/embeddings")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}")
.asString();"{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}"Create embeddings
Use this endpoint to call the provider-compatible create embeddings operation through MaxAPI.
POST
https://api.maxapi.ai
/
v1
/
embeddings
Create embeddings
curl --request POST \
--url https://api.maxapi.ai/v1/embeddings \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
'import requests
url = "https://api.maxapi.ai/v1/embeddings"
payload = {
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'text-embedding-ada-002',
input: 'The food was delicious and the waiter...'
})
};
fetch('https://api.maxapi.ai/v1/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://api.maxapi.ai/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}HttpResponse<String> response = Unirest.post("https://api.maxapi.ai/v1/embeddings")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}")
.asString();"{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}"Headers
Body
application/json
要使用的模型的 ID。您可以使用List models API 来查看所有可用模型,或查看我们的模型概述以了解它们的描述。
输入文本以获取嵌入,编码为字符串或标记数组。要在单个请求中获取多个输入的嵌入,请传递一个字符串数组或令牌数组数组。每个输入的长度不得超过 8192 个标记。
Response
200 - application/json
Request succeeded.