Generate content (Gemini)
curl --request POST \
--url https://api.dgrid.ai/v1/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello from DGrid."
}
]
}
]
}
'import requests
url = "https://api.dgrid.ai/v1/models/{model}:generateContent"
payload = { "contents": [
{
"role": "user",
"parts": [{ "text": "Hello from DGrid." }]
}
] }
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({contents: [{role: 'user', parts: [{text: 'Hello from DGrid.'}]}]})
};
fetch('https://api.dgrid.ai/v1/models/{model}:generateContent', 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/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello from DGrid.\"\n }\n ]\n }\n ]\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/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello from DGrid.\"\n }\n ]\n }\n ]\n}")
.asString();{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Chat
Generate content (Gemini)
Gemini-native generateContent interface for text chat, multimodal media recognition (images, audio, video), speech synthesis, and image generation with structured parts. Use generationConfig to request specific response modalities such as speech (speechConfig) or images (imageConfig).
POST
/
v1
/
models
/
{model}
:generateContent
Generate content (Gemini)
curl --request POST \
--url https://api.dgrid.ai/v1/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello from DGrid."
}
]
}
]
}
'import requests
url = "https://api.dgrid.ai/v1/models/{model}:generateContent"
payload = { "contents": [
{
"role": "user",
"parts": [{ "text": "Hello from DGrid." }]
}
] }
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({contents: [{role: 'user', parts: [{text: 'Hello from DGrid.'}]}]})
};
fetch('https://api.dgrid.ai/v1/models/{model}:generateContent', 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/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello from DGrid.\"\n }\n ]\n }\n ]\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/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello from DGrid.\"\n }\n ]\n }\n ]\n}")
.asString();{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Authorizations
Your DGrid API key. All endpoints use Authorization: Bearer <DGRID_API_KEY>.
Path Parameters
Target model ID, such as gemini-1.5-pro.
Body
application/json
⌘I

