Use the /v1beta path prefix. For streaming, change the method suffix to :streamGenerateContent?alt=sse.
Request parameters
Path parameters
modelstringRequiredA Gemini model placed in the /models/{model}:generateContent path. See the complete list in the model catalog.
Example:
your-gemini-model-idHeader parameters
x-goog-api-keystringRequiredThe native Gemini authentication header. Use an sk-zerofa-* key. Authorization: Bearer <key> is also accepted.
Example:
sk-zerofa-xxxContent-TypestringRequiredExample:
application/jsonBody parametersapplication/json
contentsarrayRequiredConversation content. Each item contains an optional role and parts; a part can contain text or inlineData.
Example:
[{"parts":[{"text":"hi"}]}]generationConfigobjectOptionalSampling settings such as temperature, topP, topK, and maxOutputTokens.
Example:
{"temperature":0.7}systemInstructionobjectOptionalThe system instruction.
Example:
{"parts":[{"text":"..."}]}toolsarrayOptionalTools such as functionDeclarations.
safetySettingsarrayOptionalSafety threshold settings.
Capabilities
- Streaming, function calling, and multimodal inputs such as inlineData images work in the native Gemini format.
- If you do not want to depend on the Gemini format, use Chat Completions to switch providers with the same OpenAI code. ZeroFA translates the request automatically.
Request and response bodies
Use the examples below to verify the request and response structures. To send a request, select Debug at the top of the page.
curl https://zerofa.ai/v1beta/models/your-gemini-model-id:generateContent \
-H "x-goog-api-key: sk-zerofa-xxx" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "parts": [{ "text": "Hello" }] }]
}'Response · 200
{
"candidates": [{
"content": { "role": "model", "parts": [{ "text": "Hello!" }] },
"finishReason": "STOP"
}],
"usageMetadata": {
"promptTokenCount": 4,
"candidatesTokenCount": 12,
"totalTokenCount": 16
}
}