文本/图片嵌入向量生成接口
curl --request POST \
--url https://geekai.co/api/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-3-small",
"input": [
"你好"
],
"dimensions": 1536,
"retries": 0
}
'import requests
url = "https://geekai.co/api/v1/embeddings"
payload = {
"model": "text-embedding-3-small",
"input": ["你好"],
"dimensions": 1536,
"retries": 0
}
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({model: 'text-embedding-3-small', input: ['你好'], dimensions: 1536, retries: 0})
};
fetch('https://geekai.co/api/v1/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://geekai.co/api/v1/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'text-embedding-3-small',
'input' => [
'你好'
],
'dimensions' => 1536,
'retries' => 0
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\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))
}HttpResponse<String> response = Unirest.post("https://geekai.co/api/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\n}"
response = http.request(request)
puts response.read_body{
"model": "text-embedding-3-small",
"data": [
{
"embedding": [
-0.006929,
0.0023415,
"..."
],
"index": 0
}
],
"usage": {
"prompt_tokens": 8,
"total_tokens": 8,
"prompt_tokens_details": {
"text_tokens": 123,
"image_tokens": 123
}
},
"object": "list"
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}Chat
Create Embedding
POST
/
embeddings
文本/图片嵌入向量生成接口
curl --request POST \
--url https://geekai.co/api/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-3-small",
"input": [
"你好"
],
"dimensions": 1536,
"retries": 0
}
'import requests
url = "https://geekai.co/api/v1/embeddings"
payload = {
"model": "text-embedding-3-small",
"input": ["你好"],
"dimensions": 1536,
"retries": 0
}
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({model: 'text-embedding-3-small', input: ['你好'], dimensions: 1536, retries: 0})
};
fetch('https://geekai.co/api/v1/embeddings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://geekai.co/api/v1/embeddings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'text-embedding-3-small',
'input' => [
'你好'
],
'dimensions' => 1536,
'retries' => 0
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\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))
}HttpResponse<String> response = Unirest.post("https://geekai.co/api/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/v1/embeddings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"text-embedding-3-small\",\n \"input\": [\n \"你好\"\n ],\n \"dimensions\": 1536,\n \"retries\": 0\n}"
response = http.request(request)
puts response.read_body{
"model": "text-embedding-3-small",
"data": [
{
"embedding": [
-0.006929,
0.0023415,
"..."
],
"index": 0
}
],
"usage": {
"prompt_tokens": 8,
"total_tokens": 8,
"prompt_tokens_details": {
"text_tokens": 123,
"image_tokens": 123
}
},
"object": "list"
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}Note: For setting the embedding model name, refer to the System Supported Embedding Models List. The request/response parameter structure is fully compatible with OpenAI. When switching models, you only need to modify the corresponding model name. If the model request/response parameters are inconsistent with OpenAI, GeekAI will automatically convert and align them at the underlying level.
The response data format is fully compatible with OpenAI.
cURL Request Example
curl --location 'https://geekai.dev/api/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {YOUR_GEEKAI_API_KEY}' \
--data '{
"input": [
"The food was delicious and the waiter..."
],
"model": "text-embedding-3-small"
}'
Authorizations
bearerAuthapiKeyAuth
API认证token
Body
application/json
嵌入模型
Example:
"text-embedding-3-small"
文本字符串或者图文对象列表,单行文本字符数受模型上下文长度限制
Example:
["你好"]
嵌入意图,用于指定嵌入的使用场景,目前仅 Cohere 向量模型支持该字段,当对图片进行向量化需要指定为 image
Available options:
search_document, search_query, classification, clustering, image 输出向量维度
Example:
1536
自动重试次数,默认0,表示失败不重试
Example:
0
Was this page helpful?
⌘I
