Gemini API
The Google Vertex AI / Gemini protocol is supported natively. Use the @google/genai SDK, the Vertex SDK, or any Gemini-compatible client — the request body is forwarded upstream unchanged.
Endpoints
POST https://api.eclogue.ai/v1/models/{model}:generateContent
POST https://api.eclogue.ai/v1/models/{model}:streamGenerateContent?alt=sse Note that the model goes in the URL path, not the body. :generateContent is non-streaming; :streamGenerateContent?alt=sse streams over SSE.
Example request
{
"contents": [
{
"role": "user",
"parts": [{"text": "What is the capital of France?"}]
}
],
"generationConfig": {
"maxOutputTokens": 100,
"temperature": 0.7
}
} Required headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer gw-your-key | Your gateway API key |
Content-Type | application/json | Request body format |
Request body fields
| Field | Type | Required | Description |
|---|---|---|---|
contents | array | Yes | Array of conversation turns, each with a role and parts |
generationConfig | object | No | Generation settings: maxOutputTokens, temperature, topP, topK, … |
systemInstruction | object | No | System instruction (a top-level field, not part of contents) |
tools | array | No | Function-calling definitions |
safetySettings | array | No | Safety filter configuration |
Example response
{
"candidates": [
{
"content": {
"role": "model",
"parts": [{"text": "The capital of France is Paris."}]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 8,
"candidatesTokenCount": 7,
"thoughtsTokenCount": 0,
"totalTokenCount": 15
},
"modelVersion": "gemini-2.5-flash"
} usageMetadata.thoughtsTokenCount is the number of thinking tokens (for thinking-capable models). For billing, completion_tokens = candidatesTokenCount + thoughtsTokenCount.
With curl
curl -X POST "https://api.eclogue.ai/v1/models/gemini-2.5-pro:generateContent" \
-H "Authorization: Bearer gw-your-key" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[{"text":"Hello!"}]}],
"generationConfig": {"maxOutputTokens": 100}
}' Streaming
Change :generateContent in the URL to :streamGenerateContent?alt=sse and the response becomes an SSE event stream:
curl -X POST "https://api.eclogue.ai/v1/models/gemini-2.5-pro:streamGenerateContent?alt=sse" \
-H "Authorization: Bearer gw-your-key" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role":"user","parts":[{"text":"Tell me a story"}]}],
"generationConfig": {"maxOutputTokens": 200}
}' With the @google/genai SDK
import { GoogleGenAI } from '@google/genai'
// point at the gateway and use your gateway key
const ai = new GoogleGenAI({
apiKey: 'gw-your-key-here',
httpOptions: {
baseUrl: 'https://api.eclogue.ai',
},
})
const response = await ai.models.generateContent({
model: 'gemini-2.5-pro',
contents: 'Hello!',
})
console.log(response.text) System instructions
The Vertex protocol puts system instructions in a top-level systemInstruction field, rather than inside messages as OpenAI does:
{
"systemInstruction": {
"parts": [{"text": "You are a helpful assistant. Reply in Chinese."}]
},
"contents": [
{"role": "user", "parts": [{"text": "What is 2+2?"}]}
],
"generationConfig": {"maxOutputTokens": 100}
} Supported models
Models currently available over the Vertex protocol:
gemini-2.5-progemini-2.5-flashgemini-2.5-flash-litegemini-2.5-flash-imagegemini-3.0-flash-previewgemini-3.0-pro-image-previewgemini-3.1-flash-image-previewgemini-3.1-flash-lite-previewgemini-3.1-pro-previewgemini-3.5-flash
See the models page for the full list and pricing.
Comparing the three protocols
| Aspect | OpenAI Chat | Anthropic Messages | Vertex / Gemini |
|---|---|---|---|
| Endpoint | /v1/chat/completions | /v1/messages | /v1/models/{model}:generateContent |
| Where the model goes | body.model | body.model | URL path |
| Enabling streaming | stream: true | stream: true | Change the URL to :streamGenerateContent?alt=sse |
| System instruction | First item in messages | Top-level system | Top-level systemInstruction |
| Message root field | messages[] | messages[] | contents[] + parts[] |
| Token fields | prompt_tokens / completion_tokens | input_tokens / output_tokens | promptTokenCount / candidatesTokenCount + thoughtsTokenCount |
All three protocols share the same API key, balance and billing. Pick whichever matches the SDK you already use.
Notes
- The request body is passed through unchanged. The gateway only reads
usageMetadatafrom the response to extract token counts for billing. - Google's own
aiplatform.googleapis.comendpoint is not supported yet (its GCP OAuth flow differs; it may be added later). - In streaming responses only the final chunk carries a complete
usageMetadata— this is standard Vertex behaviour, so do not expect token counts from intermediate chunks.