> ## Documentation Index
> Fetch the complete documentation index at: https://docs.znapai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Vertex Text generation

***

## Request

<CodeGroup>
  ```shellscript cURL theme={null}
  curl --location "https://api.znapai.com/v1beta1/projects/default/locations/global/publishers/google/models/gemini-2.5-flash-lite: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": "Say hello world"}]}
          ]
        }'
  ```
</CodeGroup>

## Response

```json theme={null}
{
    "candidates": [
        {
            "content": {
                "role": "model",
                "parts": [
                    {
                        "text": "Hello world"
                    }
                ]
            },
            "finishReason": "STOP",
            "avgLogprobs": -4.6243147850036621
        }
    ],
    "usageMetadata": {
        "promptTokenCount": 3,
        "candidatesTokenCount": 2,
        "totalTokenCount": 32,
        "trafficType": "ON_DEMAND",
        "promptTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 3
            }
        ],
        "candidatesTokensDetails": [
            {
                "modality": "TEXT",
                "tokenCount": 2
            }
        ],
        "thoughtsTokenCount": 27
    },
    "modelVersion": "gemini-2.5-flash-lite",
    "createTime": "2026-04-08T17:29:25.479946Z",
    "responseId": "dZDWacqlHdvzpt8Pud6xqAg"
}
```

***

## Parameters

<ParamField path="spend-logs-metadata" type="header" required={false}>
  An optional header used for spend logging metadata, containing JSON properties like `user_id`, `project_id`, and `env`.
</ParamField>

<ParamField path="contents" type="array" required>
  The conversation history or input prompts as an array of content objects.

  <Expandable title="contents[]" defaultOpen="True">
    <ResponseField name="role" type="string">
      The role of the creator of the content (e.g. `"user"` or `"model"`).
    </ResponseField>

    <ResponseField name="parts" type="array" required>
      An ordered list of parts that constitute a single message turn.

      <Expandable title="parts[]" defaultOpen="True">
        <ResponseField name="text" type="string">
          The text prompt or response content.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="systemInstruction" type="object">
  System instructions that provide context, rules, or guidelines to the model.

  <Expandable title="systemInstruction" defaultOpen="False">
    <ResponseField name="parts" type="array" required>
      An ordered list of parts that constitute the system instruction.

      <Expandable title="parts[]">
        <ResponseField name="text" type="string">
          The text content of the system instruction.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="generationConfig" type="object">
  Configuration options for model generation and outputs.

  <Expandable title="generationConfig" defaultOpen="False">
    <ResponseField name="temperature" type="number">
      Controls the randomness of the output.
    </ResponseField>

    <ResponseField name="topP" type="number">
      The maximum cumulative probability of tokens to consider when sampling.
    </ResponseField>

    <ResponseField name="topK" type="integer">
      The maximum number of tokens to consider when sampling.
    </ResponseField>

    <ResponseField name="candidateCount" type="integer">
      Number of generated responses to return.
    </ResponseField>

    <ResponseField name="maxOutputTokens" type="integer">
      The maximum number of tokens to include in a candidate.
    </ResponseField>

    <ResponseField name="stopSequences" type="array">
      A list of strings that tell the model to stop generating text.
    </ResponseField>

    <ResponseField name="responseMimeType" type="string">
      Output response mimetype of the generated candidate text (e.g. `text/plain` or `application/json`).
    </ResponseField>

    <ResponseField name="responseSchema" type="object">
      Output response schema of the generated candidate text when `responseMimeType` is `application/json`. Schema must be a subset of the OpenAPI schema.
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="safetySettings" type="array">
  A list of unique safety settings for blocking unsafe content.

  <Expandable title="safetySettings[]" defaultOpen="False">
    <ResponseField name="category" type="string">
      The category for this setting (e.g. `HARM_CATEGORY_HATE_SPEECH`).
    </ResponseField>

    <ResponseField name="threshold" type="string">
      Block threshold for this category (e.g. `BLOCK_MEDIUM_AND_ABOVE`).
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="tools" type="array">
  A list of `Tools` the model may use to generate the next response. Supported tools are function declarations, code execution, and Google Search.

  <Expandable title="tools[]" defaultOpen="False">
    <ResponseField name="functionDeclarations" type="array">
      A list of function declarations the model can call.

      <Expandable title="functionDeclarations[]">
        <ResponseField name="name" type="string" required>
          The name of the function to call.
        </ResponseField>

        <ResponseField name="description" type="string">
          A description of what the function does.
        </ResponseField>

        <ResponseField name="parameters" type="object">
          Describes the parameters for the function in JSON Schema format.

          <Expandable title="parameters">
            <ResponseField name="type" type="string">
              The type of the parameters object. Usually `"object"`.
            </ResponseField>

            <ResponseField name="properties" type="object">
              A map of parameter names to their schema definitions.
            </ResponseField>

            <ResponseField name="required" type="array">
              List of required parameter names.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="codeExecution" type="object">
      Enables the model to execute code as part of generation. Pass an empty object `{}` to enable.
    </ResponseField>

    <ResponseField name="googleSearch" type="object">
      Tool to support Google Search grounding in model responses. Pass an empty object `{}` to enable.
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="toolConfig" type="object">
  Tool configuration for any `Tool` specified in the request.

  <Expandable title="toolConfig" defaultOpen="False">
    <ResponseField name="functionCallingConfig" type="object">
      Configuration for function calling behavior.

      <Expandable title="functionCallingConfig">
        <ResponseField name="mode" type="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
        </ResponseField>

        <ResponseField name="allowedFunctionNames" type="array">
          Optional. When `mode` is `"ANY"`, limits the model to only call functions from this list.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ParamField>

***

## Params to Avoid

| Param                 | Reason                                                                       |
| --------------------- | ---------------------------------------------------------------------------- |
| `model`               | Model is specified in the URL path                                           |
| `spend-logs-metadata` | This metadata must be passed as an HTTP header, not in the JSON request body |
