DocsAPI referenceGemini API
Gemini API
Google Gemini-compatible endpoints — generateContent, streamGenerateContent, countTokens.
POST
/v1beta/models/{model}:generateContentA chat endpoint compatible with the Google Gemini API request body. The model name and action live in the path ({model}:generateContent); authenticate with the x-goog-api-key header.
Google's official ?key= query parameter is not supported — the key must be in the x-goog-api-key header (the Google GenAI SDK uses that header by default).
Request body
| Field | Type | Required | Description |
|---|---|---|---|
contents | array | Yes | Conversation content: each item has a role (user/model) and parts (text or inline media). |
systemInstruction | object | No | System prompt ({ "parts": [{ "text": … }] }). |
generationConfig | object | No | Generation parameters: temperature, maxOutputTokens, etc. |
curl "https://api.soleapi.com/v1beta/models/gemini-2.5-pro:generateContent" \
-H "x-goog-api-key: $SOLEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Write a haiku about the sea"}]}]
}'Response
{
"candidates": [
{
"content": {
"parts": [{ "text": "Waves fold into foam..." }],
"role": "model"
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 14,
"candidatesTokenCount": 23,
"totalTokenCount": 37
}
}Streaming generation
POST
/v1beta/models/{model}:streamGenerateContentAppend ?alt=sse to stream incrementally over SSE — each data: line is a response fragment; without alt=sse you get one complete JSON array. See Streaming.
Count tokens
POST
/v1beta/models/{model}:countTokenscurl "https://api.soleapi.com/v1beta/models/gemini-2.5-pro:countTokens" \
-H "x-goog-api-key: $SOLEAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Write a haiku about the sea"}]}]
}'
# => { "totalTokens": 14 }