Request
curl --location "https://api.znapai.com/v1beta1/projects/default/locations/global/publishers/google/models/gemini-3.1-flash-image-preview:generateContent" \
--header "Authorization: Bearer $ZnapAI_API_KEY" \
--header "Content-Type: application/json" \
--header 'spend-logs-metadata: {"user_id": "user-123", "project_id": "proj_abc", "env": "production"}' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate an image of an F35 flying"
}
]
}
],
"generationConfig": {
"candidateCount": 1
}
}'
Response
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "iVBORwZP...ggQGt+y0AAAAASUVORK5CYII="
}
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 6,
"candidatesTokenCount": 1290,
"totalTokenCount": 1296,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 6
}
],
"candidatesTokensDetails": [
{
"modality": "IMAGE",
"tokenCount": 1290
}
]
},
"modelVersion": "gemini-3.1-flash-image-preview",
"createTime": "2026-04-08T17:31:32.596160Z",
"responseId": "9JDWacCxJNiipt8Psd7RoQs"
}
Image from base64 data

Parameters
header
An optional header used for spend logging metadata, containing JSON properties like
user_id, project_id, and env.array
required
The conversation history or input prompts as an array of content objects.
object
object
Configuration options for the generation.
Show generationConfig
Show generationConfig
integer
default:1
Number of generated images to return.
number
Controls the randomness of the output.
number
The maximum cumulative probability of tokens to consider when sampling.
number
The maximum number of tokens to consider when sampling.
number
The maximum number of tokens to include in a candidate.
array
A list of sequences that will stop generation.
array
Allowed modalities of the output. Use
["IMAGE", "TEXT"].array
array
A list of tools the model may call.
Show tools[]
Show tools[]
object
Configuration for Google Search grounding.
object
Params to Avoid
| Param | Reason |
|---|---|
prompt, n, size, quality | OpenAI/Azure OpenAI parameters; sending these at the root level will fail schema validation. Use contents and generationConfig instead. |
response_format, output_format | Not supported by the Gemini API. Response format is determined by responseModalities. |
background, output_compression, style | OpenAI/Azure specific parameters; not supported by Gemini models. |
generationConfig.responseMimeType: "application/json" | Not supported when responseModalities includes "IMAGE". |
google_search | Snake case is used in the Gemini Developer API, but the Vertex AI API requires camelCase (googleSearch). |
spend-logs-metadata | This metadata must be passed as an HTTP header, not in the JSON request body |
Ensure you do not mix OpenAI or Azure-specific parameters (such as
prompt, size, quality, or n) with Gemini/Vertex AI request structure. Vertex AI expects prompt text inside the nested contents.parts object using camelCase keys.