Create embeddings
curl --request POST \
--url https://api.dgrid.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-ada-002",
"input": "The quick brown fox"
}
'import requests
url = "https://api.dgrid.ai/v1/embeddings"
payload = {
"model": "text-embedding-ada-002",
"input": "The quick brown fox"
}
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-ada-002', input: 'The quick brown fox'})
};
fetch('https://api.dgrid.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.dgrid.ai/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The quick brown fox\"\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://api.dgrid.ai/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The quick brown fox\"\n}")
.asString();{
"object": "<string>",
"data": [
{
"object": "<string>",
"embedding": [
123
],
"index": 123
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}嵌入
建立嵌入
OpenAI-compatible embeddings for retrieval, clustering, and semantic similarity workloads.
POST
/
v1
/
embeddings
Create embeddings
curl --request POST \
--url https://api.dgrid.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "text-embedding-ada-002",
"input": "The quick brown fox"
}
'import requests
url = "https://api.dgrid.ai/v1/embeddings"
payload = {
"model": "text-embedding-ada-002",
"input": "The quick brown fox"
}
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-ada-002', input: 'The quick brown fox'})
};
fetch('https://api.dgrid.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.dgrid.ai/v1/embeddings"
payload := strings.NewReader("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The quick brown fox\"\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://api.dgrid.ai/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The quick brown fox\"\n}")
.asString();{
"object": "<string>",
"data": [
{
"object": "<string>",
"embedding": [
123
],
"index": 123
}
],
"model": "<string>",
"usage": {
"prompt_tokens": 123,
"total_tokens": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}授權
Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.
主體
application/json
⌘I

