Gemini Generate Content
Invoke Google Gemini models natively with official @google/genai or google-genai SDKs and Gemini CLI, retaining native multimodal parts, systemInstruction, and thinking configuration.
POST
https://api.vanix.io/v1beta/models/{model}:generateContentPOST
https://api.vanix.io/v1beta/models/{model}:streamGenerateContent?alt=sseAuthentication
Pass your Vanix AI token via the x-goog-api-key header (recommended) or ?key=$VANIX_API_KEY query parameter.
Request Body Parameters
contentsarray<object>required Ordered list of content turns, each containing
role (user or model) and parts (text, inlineData, functionCall, functionResponse). systemInstructionobjectoptional Top-level system prompt block:
{"parts": [{"text": "..."}]}. generationConfigobjectoptional Sampling and output controls including
temperature, maxOutputTokens, responseMimeType, and thinkingConfig. toolsarray<object>optional Native Gemini function declarations or provider tools such as Google Search grounding where supported by the upstream channel.
Code Examples
bash
curl "https://api.vanix.io/v1beta/models/gemini-2.5-flash:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $VANIX_API_KEY" \
-d '{
"systemInstruction": {"parts": [{"text": "Reply in JSON only."}]},
"contents": [{
"role": "user",
"parts": [{"text": "Return {\"status\":\"ok\",\"gateway\":\"vanix\"}"}]
}],
"generationConfig": {"responseMimeType": "application/json"}
}'bash
curl -N "https://api.vanix.io/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $VANIX_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Explain token buckets in 3 sentences."}]}]
}'python
import os
from google import genai
from google.genai import types
client = genai.Client(
api_key=os.environ["VANIX_API_KEY"],
http_options=types.HttpOptions(base_url="https://api.vanix.io"),
)
resp = client.models.generate_content(
model="gemini-2.5-flash",
contents="Explain token buckets in 3 sentences.",
)
print(resp.text)