Request
curl --location 'https://api.znapai.com/v1beta1/projects/default/locations/global/publishers/google/models/gemini-2.5-flash-image: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": "Edit this image and draw a smiley in it"
},
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wAARCABAAEADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwCxRRRXsHAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAf/9k="
}
}
]
}
],
"generationConfig": {
"responseModalities": ["IMAGE", "TEXT"]
}
}'
Input

Response
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "iVBORw0KGgo...uQmCC"
}
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 1812,
"candidatesTokenCount": 1290,
"totalTokenCount": 3102,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 6
},
{
"modality": "IMAGE",
"tokenCount": 1806
}
],
"candidatesTokensDetails": [
{
"modality": "IMAGE",
"tokenCount": 1290
}
]
},
"modelVersion": "gemini-2.5-flash-image",
"createTime": "2026-04-08T17:50:54.995975Z",
"responseId": "fpXWaYflPLqnpt8P8svDwAE"
}
Image from base64 data
.png?fit=max&auto=format&n=YqLy5V4XqDwqd3Qg&q=85&s=9a2d0f35a3e83a0b64671181febdc1bf)
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.
Show contents[]
Show contents[]
string
The role of the creator of the content (e.g.
"user" or "model").array
required
An ordered list of parts that constitute a single message turn.
object
array
A list of
Tools the model may use to generate the next response. Supported tools are function declarations, code execution, and Google Search.Show tools[]
Show tools[]
array
A list of function declarations the model can call.
Show functionDeclarations[]
Show functionDeclarations[]
string
required
The name of the function to call.
string
A description of what the function does.
object
Enables the model to execute code as part of generation. Pass an empty object
{} to enable.object
Tool to support Google Search grounding in model responses. Pass an empty object
{} to enable.object
Tool configuration for any
Tool specified in the request.Show toolConfig
Show toolConfig
object
Configuration for function calling behavior.
Show functionCallingConfig
Show functionCallingConfig
string
Controls how the model uses the provided functions. One of:
"AUTO"— model decides whether to call a function or respond in text"ANY"— model must call one of the provided functions"NONE"— model must not call any functions
array
Optional. When
mode is "ANY", limits the model to only call functions from this list.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"] to request image output.array
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". |
inline_data, mime_type | Snake case keys are used in the Google GenAI Developer API, but the Vertex AI API requires camelCase (inlineData, mimeType). |
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 and the image input inside the nested contents.parts object using camelCase keys.