---
title: "Gemini Generating Content"
method: POST
path: "/v1beta/models/{model}:{operator}"
---

# Gemini Generating Content

`POST /v1beta/models/{model}:{operator}`

Generates content using Google Gemini models via the native Gemini API format. Supports text generation, multimodal inputs, thinking/reasoning, function calling, Google Search grounding, structured output, and streaming. CometAPI proxies requests to Google's Gemini API — use this endpoint when you need Gemini-native features not available through the OpenAI-compatible endpoint.

## Path parameters

- `model` string, required
- `operator` 'generateContent' | 'streamGenerateContent?alt=sse', required

## Request body

- object
  - `contents` object[] — Conversation content. Each entry has an optional `role` (`user` or `model`) and a `parts` array.
    - `role` 'user' | 'model' — The role of the content author. Use `user` for user messages and `model` for assistant responses in multi-turn conversations. Can be omitted for single-turn requests.
    - `parts` object[] — The content parts for this turn. Supports text, inline base64 media, public file URLs, and function call results.
      - `text` string — Text content of this part.
      - `inlineData` object — Inline binary media sent as base64 in the request. Use this for local image, audio, video, PDF, or other supported media files that are small enough to include in the JSON body. Omit this field when using `fileData`.
        - `mimeType` string — The MIME type of the media bytes, such as `image/png`, `audio/mpeg`, `video/mp4`, or `application/pdf`.
        - `data` string — Base64-encoded file bytes. Do not include a `data:video/mp4;base64,` prefix.
      - `fileData` object — A media file referenced by URL. Use this for public HTTPS video, image, audio, or document URLs that the model provider can fetch without authentication. Omit this field when using `inlineData`.
        - `mimeType` string — The MIME type of the referenced file, such as `video/mp4`, `image/png`, `audio/mpeg`, or `application/pdf`.
        - `fileUri` string — A public HTTPS URL for the media file. The URL must not require cookies, private headers, or a signed-in session.
      - `functionCall` object — A function call generated by the model.
        - `name` string — The function name.
        - `args` object — The function arguments as a JSON object.
      - `functionResponse` object — The result of a function call, provided by the user.
        - `name` string — The function name.
        - `response` object — The function response as a JSON object.
  - `systemInstruction` object — System instructions that guide the model's behavior across the entire conversation. Text only.
    - `parts` object[] — Content parts of the system instruction.
      - `text` string — The system instruction text.
  - `tools` object[] — Tools the model may use to generate responses. Supports function declarations, Google Search, Google Maps, and code execution.
    - `functionDeclarations` object[] — A list of function declarations for function calling.
      - `name` string — The function name.
      - `description` string — A description of what the function does.
      - `parameters` object — The function parameters as a JSON Schema object.
    - `googleSearch` object — Enable Google Search grounding. Pass an empty object `{}` to enable.
    - `googleMaps` object — Enable Google Maps grounding. Pass an empty object `{}` to enable.
    - `codeExecution` object — Enable code execution. Pass an empty object `{}` to enable.
  - `toolConfig` object — Configuration for tool usage, such as function calling mode.
    - `functionCallingConfig` object — Configuration for function calling behavior.
      - `mode` 'AUTO' | 'ANY' | 'NONE' — The function calling mode.
      - `allowedFunctionNames` string[] — Restrict the model to calling only these functions. Only effective when `mode` is `ANY`.
    - `retrievalConfig` object — Configuration for retrieval-based tools (e.g., Google Maps location context).
      - `latLng` object — Latitude and longitude for location-based grounding.
        - `latitude` number — Latitude in degrees.
        - `longitude` number — Longitude in degrees.
  - `safetySettings` object[] — Safety filter settings. Override default thresholds for specific harm categories.
    - `category` 'HARM_CATEGORY_HARASSMENT' | 'HARM_CATEGORY_HATE_SPEECH' | 'HARM_CATEGORY_SEXUALLY_EXPLICIT' | 'HARM_CATEGORY_DANGEROUS_CONTENT' | 'HARM_CATEGORY_CIVIC_INTEGRITY' — The harm category to configure.
    - `threshold` 'BLOCK_NONE' | 'BLOCK_ONLY_HIGH' | 'BLOCK_MEDIUM_AND_ABOVE' | 'BLOCK_LOW_AND_ABOVE' | 'OFF' — The blocking threshold for this category.
  - `generationConfig` object — Configuration for model generation behavior including temperature, output length, and response format.
    - `temperature` number — Controls randomness in output generation. Range: 0.0–2.0. For Gemini 3 models, keeping the default (1.0) is strongly recommended — lower values may cause looping or degraded reasoning.
    - `topP` number — Nucleus sampling threshold. Tokens are considered in order of probability until the cumulative probability reaches this value.
    - `topK` integer — Maximum number of tokens to consider when sampling. Not supported by all models.
    - `maxOutputTokens` integer — Maximum number of tokens in the generated response. The default varies by model.
    - `candidateCount` integer — Number of response candidates to generate. Defaults to 1. Not supported by Gemini 1.0 models.
    - `stopSequences` string[] — Up to 5 character sequences that will stop output generation. The stop sequence is not included in the response.
    - `seed` integer — Seed for deterministic generation. If not set, a random seed is used.
    - `presencePenalty` number — Penalizes tokens that have already appeared in the response (binary on/off per token). Positive values encourage diverse vocabulary.
    - `frequencyPenalty` number — Penalizes tokens proportionally to how many times they have appeared. Positive values discourage repetition.
    - `responseMimeType` 'text/plain' | 'application/json' | 'text/x.enum' — The MIME type for the response. Use `application/json` for JSON mode, `text/x.enum` for enum output, or `text/plain` (default) for free text.
    - `responseSchema` object — Output schema for structured responses (JSON Schema subset). Requires `responseMimeType` to be `application/json`.
    - `responseModalities` string[] — The expected modalities in the response. Use `["TEXT"]` for text-only, `["IMAGE"]` for images, or `["TEXT", "IMAGE"]` for both. An empty list defaults to text only.
    - `responseLogprobs` boolean — If `true`, include log probabilities in the response.
    - `logprobs` integer — Number of top log probabilities to return per token (0–20). Only valid when `responseLogprobs` is `true`.
    - `thinkingConfig` object — Controls the model's internal reasoning (thinking) process. Supported by Gemini 2.5 and later models.
      - `thinkingBudget` integer — Maximum number of thinking tokens the model may use. Use this for fine-grained control (Gemini 2.5 models).
      - `thinkingLevel` 'MINIMAL' | 'LOW' | 'MEDIUM' | 'HIGH' — Controls the depth of reasoning using a preset level. Recommended for Gemini 3 models. Using this with earlier models may result in an error.
      - `includeThoughts` boolean — If `true`, include the model's thinking process in the response parts.
    - `imageConfig` object — Configuration for image generation. Only applicable to models that support image output.
      - `aspectRatio` '1:1' | '2:3' | '3:2' | '3:4' | '4:3' | '4:5' | '5:4' | '9:16' | '16:9' | '21:9' — The aspect ratio for generated images.
      - `imageSize` '1K' | '2K' | '4K' — The resolution of generated images.
    - `mediaResolution` 'MEDIA_RESOLUTION_LOW' | 'MEDIA_RESOLUTION_MEDIUM' | 'MEDIA_RESOLUTION_HIGH' — Resolution for processing input media files.
  - `cachedContent` string — The name of cached content to use as context. Format: `cachedContents/{id}`. See the Gemini context caching documentation for details.

## Response `200`

Successful response. For streaming requests, the response is a stream of SSE events, each containing a `GenerateContentResponse` JSON object prefixed with `data: `.

- object
  - `candidates` object[] — The generated response candidates.
    - `content` object — The generated content.
      - `role` string — Always `model` for generated responses.
      - `parts` object[] — The content parts of the response.
        - `text` string — Generated text content.
        - `functionCall` object — A function call request from the model (when using function calling tools).
          - `name` string — Name of the function the model wants to call.
          - `args` object — Function arguments as a JSON object.
        - `inlineData` object — Inline binary data (e.g., generated images).
          - `mimeType` string — MIME type of the inline data, such as `image/png`.
          - `data` string — Base64-encoded bytes of the inline data.
        - `thought` boolean — `true` if this part contains the model's thinking/reasoning process (when `includeThoughts` is enabled).
    - `finishReason` 'STOP' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'LANGUAGE' | 'OTHER' | 'BLOCKLIST' | 'PROHIBITED_CONTENT' | 'SPII' | 'MALFORMED_FUNCTION_CALL' — The reason the model stopped generating tokens.
    - `safetyRatings` object[] — Safety ratings for this candidate.
      - `category` string — Safety category this rating applies to.
      - `probability` string — Probability level for harmful content in this category, such as `NEGLIGIBLE` or `HIGH`.
      - `blocked` boolean — Whether content was blocked for this category.
    - `citationMetadata` object — Citation information for model-generated content.
      - `citationSources` object[] — Sources cited for the generated content.
        - `startIndex` integer — Start byte index of the cited span in the output.
        - `endIndex` integer — End byte index of the cited span in the output.
        - `uri` string — URI of the cited source.
        - `license` string — License of the cited source when known.
    - `tokenCount` integer — Token count for this candidate.
    - `avgLogprobs` number — Average log probability score of this candidate.
    - `groundingMetadata` object — Grounding metadata when Google Search or other grounding tools are used.
      - `groundingChunks` object[] — Web sources that ground the response when Google Search grounding runs.
        - `web` object — A web source used for grounding.
          - `uri` string — URI of the grounding source.
          - `title` string — Title of the grounding source page.
      - `groundingSupports` object[] — Mapping between output text segments and the grounding chunks that support them.
        - `groundingChunkIndices` integer[] — Indexes into `groundingChunks` that support this segment.
        - `confidenceScores` number[] — Support confidence per grounding chunk, between 0 and 1.
        - `segment` object — The output text segment this support entry covers.
          - `startIndex` integer — Start byte index of the segment.
          - `endIndex` integer — End byte index of the segment.
          - `text` string — Text of the segment.
      - `webSearchQueries` string[] — Search queries the model issued for grounding.
    - `index` integer — Index of this candidate in the list of response candidates.
  - `promptFeedback` object — Feedback on the prompt, including safety blocking information.
    - `blockReason` 'SAFETY' | 'OTHER' | 'BLOCKLIST' | 'PROHIBITED_CONTENT' — If set, the prompt was blocked.
    - `safetyRatings` object[] — Safety ratings for the prompt.
      - `category` string — Safety category this rating applies to.
      - `probability` string — Probability level for harmful content in this category.
      - `blocked` boolean — Whether the prompt was blocked for this category.
  - `usageMetadata` object — Token usage statistics for the request.
    - `promptTokenCount` integer — Number of tokens in the prompt.
    - `candidatesTokenCount` integer — Number of tokens across all generated candidates.
    - `totalTokenCount` integer — Total token count (prompt + candidates + thinking).
    - `trafficType` string — The traffic type used for processing (e.g., `ON_DEMAND`).
    - `thoughtsTokenCount` integer — Number of tokens used for the model's internal thinking process.
    - `promptTokensDetails` object[] — Token count breakdown by input modality.
      - `modality` string — Input modality this entry counts, such as `TEXT` or `VIDEO`.
      - `tokenCount` integer — Prompt tokens for this modality.
    - `candidatesTokensDetails` object[] — Token count breakdown by output modality.
      - `modality` string — Output modality this entry counts.
      - `tokenCount` integer — Output tokens for this modality.
  - `modelVersion` string — The model version that generated this response.
  - `createTime` string — The timestamp when this response was created (ISO 8601 format).
  - `responseId` string — Unique identifier for this response.

---

[API](https://skmtc.net/cometapi/apis/create-api-key.md) · [All operations](https://skmtc.net/cometapi/apis/create-api-key/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cometapi/create-api-key/versions/0863102dbf34/schema)
