Skip to main content
POST
/
v1beta
/
models
/
gemini-2.5-flash-lite:generateContent

Authorization

  • Auth Type: Bearer Auth (In: header)
  • Format: Authorization: Bearer <YOUR_API_KEY>
  • Description: Use Bearer <YOUR_API_KEY>. Format: Authorization: Bearer sk-xxxxxx.
  • API Key: where API Key is your AGCloud API KEY
Google Gemini API provides two actions for content generation, distinguished by whether they return responses incrementally (streaming) or all at once (non-streaming).

Request Body

Core Parameters

FieldTypeRequiredDefaultDescription
contentsarray-Content of the current conversation with the model. For single-turn queries, this contains one instance. For multi-turn queries (e.g., chat), this contains the conversation history and the latest request.
>contents.rolestring-The role of the message sender. Can be user model.
>contents.partsarray-The content parts of the message, which can contain different types of content (text, inlineData, etc.).
>>contents.parts.textstring-Text content of the part. For multimodal input details

Advanced Parameters

FieldTypeRequiredDescription
toolsarray<object>-List of tools the model may use to generate the next response. Supported tools include Function and codeExecution.
toolConfigobject-Configuration for any tools specified in the request.
generationConfigobject-Configuration options for content generation.
safetySettingsarray<object>-List of unique SafetySetting instances for filtering unsafe content. Each SafetyCategory should have at most one setting
Web Search Grounding allows Gemini models to connect with real-time web content, providing more accurate answers with verifiable sources.
{
  "tools": [
    {
      "google_search": {}
    }
  ]
}

Tools Structure

FieldTypeRequiredRangeDescription
googleSearchobject--Array of tools to use for the request.
>googleSearch.timeRangeFilterobject--Optional time range filter for the search.
>>googleSearch.timeRangeFilter.startTimestring-2024-01-01T00:00:00Z or timestampOptional start time for the search in ISO 8601 format or timestamp.
>>googleSearch.timeRangeFilter.endTimestring-2024-01-01T00:00:00Z or timestampOptional end time for the search in ISO 8601 format or timestamp. Note: For Gemini 3 models, the time span cannot exceed 24 hours.

Tool Config Structure

FieldTypeRequiredRangeDescription
functionCallingConfigobject--Control tool/function call behavior
>functionCallingConfig.modeenum-MODE_UNSPECIFIED
AUTO
ANY
NONE
Control model whether to call tools.
>functionCallingConfig.allowedFunctionNamesarray<string>-google_searchRestricting the functions that can be called. Must be google_search

Generation Config Structure

FieldTypeRangeDescription
temperaturenumber0.0 - 1.0Controls the randomness of the output.
topPnumber0.0 - 1.0Nucleus sampling probability threshold.
topKinteger-Top-k sampling parameter.
maxOutputTokensinteger-Maximum number of tokens to generate.
thinkingConfigobject-Indicates whether to include thoughts in the response. If true, thoughts are only returned when thinking is enabled.
>thinkingConfig.includeThoughtsboolean-Sequences at which to stop generation.
>thinkingConfig.thinkingBudgetinteger0 - 24576For Gemini 2.x models. Specifies the maximum number of tokens for generated thoughts.
>thinkingConfig.thinkingLevelenumlow
medium
high
minimal
Recommended for Gemini 3 or newer models. Using it with older models may cause errors. Default high
imageConfigobject-Configuration for image generation. If set for models that don’t support these configuration options, the system will return an error.
>imageConfig.aspectRatiostring1:1
2:3
3:2
3:4
4:3
9:16
16:9
21:9
Aspect ratio of the generated image. If not specified, the model will select the appropriate aspect ratio based on the specified content.
>imageConfig.imageSizestring1k
2k
4k
Approximate size of the generated image. If not specified, default 1k.
mediaResolutionenumMEDIA_RESOLUTION_UNSPECIFIED
MEDIA_RESOLUTION_LOW
MEDIA_RESOLUTION_MEDIUM
MEDIA_RESOLUTION_HIGH
If specified, uses the specified media resolution.
Note: thinkingConfig.thinking_level is only supported on Gemini 3.0 and above. It cannot be used together with thinking_budget; doing so will return an error.

Safety Settings Structure

FieldTypeRequiredRangeDescription
categorystringHARM_CATEGORY_HATE_SPEECH HARM_CATEGORY_SEXUALLY_EXPLICIT HARM_CATEGORY_DANGEROUS_CONTENT HARM_CATEGORY_HARASSMENT HARM_CATEGORY_CIVIC_INTEGRITYThe harm category to apply the safety setting to.
thresholdstringBLOCK_ONLY_HIGH BLOCK_MEDIUM_AND_ABOVE BLOCK_LOW_AND_ABOVE BLOCK_NONEThe threshold for blocking content.

Multimodal input

{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "inlineData": {
            "mimeType": "image/jpeg",
            "data": "base64-encoded-image-data"
          }
        },
        {
          "text": "Describe this image."
        }
      ]
    }
  ]
}

Input Parameters

FieldTypeRequiredRangeDescription
partsarray<object>text
inlineData
fileData
The content parts of the message, which can contain different types of content .
>parts.inlineDataobject-Inline media content. If used, data must be base64-encoded.
>>parts.inlineData.mimeTypestring✅ if inlineData is usedapplication/pdf
image/jpeg
The IANA-standard MIME type of the source data. If the provided MIME type is not supported, the system will return an error.
>>parts.inlineData.datastring✅ if inlineData is used-Base64 encoded data.
>parts.fileDataobject--File media content. If used, fileUri must be provided.
>>parts.fileData.mimeTypestring-application/pdf
image/jpeg
The IANA-standard MIME type of the source data.
>>parts.fileData.fileUristring✅ if fileData is used-The URI of the file to be processed.