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

# Gemini Generate Content

> Use DeerAPI to call the Gemini Generate Content endpoint with request details, response details, examples, and an OpenAPI playground.

## Overview

Use this endpoint to call the Gemini Generate Content workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.

## Before you start

Use the DeerAPI base URL and pass your API Key in the `Authorization` header:

```text theme={null}
https://api.deerapi.com
```

```text theme={null}
Authorization: Bearer $DEERAPI_KEY
```

## Model selection

Choose a current model ID from the [live pricing page](https://api.deerapi.com/pricing). Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.

## Implementation notes

* Use the OpenAPI playground for the exact request fields accepted by this endpoint.
* Keep API Keys on the server side when you build production applications.
* Log the request ID from failed calls so support can investigate the request.
* Retry `429`, `500`, and `503` responses with exponential backoff.


## OpenAPI

````yaml /api/openapi/text/gemini/post-gemini-text.openapi.json POST /v1beta/models/{model}:{function}
openapi: 3.1.0
info:
  title: Gemini Text API
  version: 1.0.0
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /v1beta/models/{model}:{function}:
    post:
      summary: Gemini Text API
      operationId: post_v1beta_models_model_function
      parameters:
        - name: model
          in: path
          required: true
          description: Use this field according to the endpoint schema.
          schema:
            type: string
        - name: function
          in: path
          required: true
          description: Use this field according to the endpoint schema.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Use this field according to the endpoint schema.
              additionalProperties: true
              required:
                - contents
              properties:
                contents:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    description: Use this field according to the endpoint schema.
                    properties:
                      role:
                        type: string
                        description: Use this field according to the endpoint schema.
                        enum:
                          - user
                          - model
                      parts:
                        type: array
                        description: Use this field according to the endpoint schema.
                        items:
                          type: object
                          description: Use this field according to the endpoint schema.
                          properties:
                            text:
                              type: string
                              description: Use this field according to the endpoint schema.
                            inlineData:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                            fileData:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                            functionCall:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                            functionResponse:
                              type: object
                              description: Use this field according to the endpoint schema.
                              additionalProperties: true
                          additionalProperties: true
                    additionalProperties: true
                  default:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
                systemInstruction:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    role:
                      type: string
                      description: Use this field according to the endpoint schema.
                    parts:
                      type: array
                      items:
                        type: object
                        properties:
                          text:
                            type: string
                        additionalProperties: true
                  additionalProperties: true
                tools:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    additionalProperties: true
                toolConfig:
                  type: object
                  description: Use this field according to the endpoint schema.
                  additionalProperties: true
                safetySettings:
                  type: array
                  description: Use this field according to the endpoint schema.
                  items:
                    type: object
                    properties:
                      category:
                        type: string
                        description: Use this field according to the endpoint schema.
                        enum:
                          - HARM_CATEGORY_HARASSMENT
                          - HARM_CATEGORY_HATE_SPEECH
                          - HARM_CATEGORY_SEXUALLY_EXPLICIT
                          - HARM_CATEGORY_DANGEROUS_CONTENT
                          - HARM_CATEGORY_CIVIC_INTEGRITY
                      threshold:
                        type: string
                        description: Use this field according to the endpoint schema.
                        enum:
                          - 'OFF'
                          - BLOCK_NONE
                          - BLOCK_ONLY_HIGH
                          - BLOCK_MEDIUM_AND_ABOVE
                          - BLOCK_LOW_AND_ABOVE
                    additionalProperties: true
                cachedContent:
                  type: string
                  description: Use this field according to the endpoint schema.
                store:
                  type: boolean
                  description: Use this field according to the endpoint schema.
                generationConfig:
                  type: object
                  description: Use this field according to the endpoint schema.
                  properties:
                    responseModalities:
                      type: array
                      description: Use this field according to the endpoint schema.
                      items:
                        type: string
                        enum:
                          - TEXT
                          - IMAGE
                          - AUDIO
                    temperature:
                      type: number
                      description: Use this field according to the endpoint schema.
                      minimum: 0
                      maximum: 2
                    maxOutputTokens:
                      type: integer
                      description: Use this field according to the endpoint schema.
                    topP:
                      type: number
                      description: Use this field according to the endpoint schema.
                      minimum: 0
                      maximum: 1
                    topK:
                      type: integer
                      description: Use this field according to the endpoint schema.
                    stopSequences:
                      type: array
                      description: Use this field according to the endpoint schema.
                      items:
                        type: string
                    seed:
                      type: integer
                      description: Use this field according to the endpoint schema.
                    presencePenalty:
                      type: number
                      description: Use this field according to the endpoint schema.
                    frequencyPenalty:
                      type: number
                      description: Use this field according to the endpoint schema.
                    responseMimeType:
                      type: string
                      description: Use this field according to the endpoint schema.
                    responseSchema:
                      type: object
                      description: Use this field according to the endpoint schema.
                      additionalProperties: true
                    responseJsonSchema:
                      description: Use this field according to the endpoint schema.
                    candidateCount:
                      type: integer
                      description: Use this field according to the endpoint schema.
                    thinkingConfig:
                      type: object
                      description: Use this field according to the endpoint schema.
                      properties:
                        includeThoughts:
                          type: boolean
                          description: Use this field according to the endpoint schema.
                        thinkingBudget:
                          type: integer
                          description: Use this field according to the endpoint schema.
                        thinkingLevel:
                          type: string
                          description: Use this field according to the endpoint schema.
                          enum:
                            - MINIMAL
                            - LOW
                            - MEDIUM
                            - HIGH
                      additionalProperties: true
                    responseLogprobs:
                      type: boolean
                      description: Use this field according to the endpoint schema.
                    logprobs:
                      type: integer
                      description: Use this field according to the endpoint schema.
                    speechConfig:
                      type: object
                      description: Use this field according to the endpoint schema.
                      additionalProperties: true
                    imageConfig:
                      type: object
                      description: Use this field according to the endpoint schema.
                      properties:
                        aspectRatio:
                          type: string
                          description: Use this field according to the endpoint schema.
                        imageSize:
                          type: string
                          description: Use this field according to the endpoint schema.
                      additionalProperties: true
                    mediaResolution:
                      type: string
                      description: Use this field according to the endpoint schema.
                      enum:
                        - MEDIA_RESOLUTION_LOW
                        - MEDIA_RESOLUTION_MEDIUM
                        - MEDIA_RESOLUTION_HIGH
                  default:
                    responseModalities:
                      - TEXT
                  additionalProperties: true
              default:
                contents:
                  - role: user
                    parts:
                      - text: >-
                          Summarize the benefits of retry logic for production
                          API clients.
            examples:
              Default:
                summary: Gemini Text API
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
              Thinking:
                summary: Gemini Text API
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
                  generationConfig:
                    thinkingConfig:
                      includeThoughts: true
                      thinkingBudget: 1024
              Thinking_2:
                summary: Gemini Text API
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
                  generationConfig:
                    thinkingConfig:
                      thinkingLevel: LOW
              System_Instruction:
                summary: Gemini Text API
                value:
                  systemInstruction:
                    role: system
                    parts:
                      - text: >-
                          Summarize the benefits of retry logic for production
                          API clients.
                  contents:
                    - role: user
                      parts:
                        - text: The quick brown fox jumps over the lazy dog.
              Google Search:
                summary: Google Search
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
                  tools:
                    - google_search: {}
              Structured_Output:
                summary: Gemini Text API
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Summarize the benefits of retry logic for production
                            API clients.
                  generationConfig:
                    responseMimeType: application/json
                    responseSchema:
                      type: object
                      properties:
                        title:
                          type: string
                        summary:
                          type: string
                      required:
                        - title
                        - summary
            example:
              contents:
                - role: user
                  parts:
                    - text: >-
                        Summarize the benefits of retry logic for production API
                        clients.
      responses:
        '200':
          description: Use this field according to the endpoint schema.
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    description: Use this field according to the endpoint schema.
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          properties:
                            role:
                              type: string
                              description: Use this field according to the endpoint schema.
                            parts:
                              type: array
                              description: Use this field according to the endpoint schema.
                              items:
                                type: object
                                properties:
                                  text:
                                    type: string
                                    description: >-
                                      Use this field according to the endpoint
                                      schema.
                                  thought:
                                    type: boolean
                                    description: >-
                                      Use this field according to the endpoint
                                      schema.
                        finishReason:
                          type: string
                          description: Use this field according to the endpoint schema.
                          enum:
                            - STOP
                            - MAX_TOKENS
                            - SAFETY
                            - RECITATION
                            - LANGUAGE
                            - OTHER
                            - BLOCKLIST
                            - PROHIBITED_CONTENT
                            - SPII
                            - MALFORMED_FUNCTION_CALL
                        tokenCount:
                          type: integer
                          description: Use this field according to the endpoint schema.
                        avgLogprobs:
                          type: number
                          description: Use this field according to the endpoint schema.
                        groundingMetadata:
                          type: object
                          description: Use this field according to the endpoint schema.
                          additionalProperties: true
                        urlContextMetadata:
                          type: object
                          description: Use this field according to the endpoint schema.
                          additionalProperties: true
                        citationMetadata:
                          type: object
                          description: Use this field according to the endpoint schema.
                          additionalProperties: true
                        finishMessage:
                          type: string
                          description: Use this field according to the endpoint schema.
                        index:
                          type: integer
                          description: Use this field according to the endpoint schema.
                        safetyRatings:
                          type: array
                          description: Use this field according to the endpoint schema.
                          items:
                            type: object
                            properties:
                              category:
                                type: string
                              probability:
                                type: string
                  usageMetadata:
                    type: object
                    description: Use this field according to the endpoint schema.
                    properties:
                      promptTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      cachedContentTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      candidatesTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      toolUsePromptTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      thoughtsTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      totalTokenCount:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      promptTokensDetails:
                        type: array
                        description: Use this field according to the endpoint schema.
                        items:
                          type: object
                          properties:
                            modality:
                              type: string
                            tokenCount:
                              type: integer
                      candidatesTokensDetails:
                        type: array
                        description: Use this field according to the endpoint schema.
                        items:
                          type: object
                          properties:
                            modality:
                              type: string
                            tokenCount:
                              type: integer
                  modelVersion:
                    type: string
                    description: Use this field according to the endpoint schema.
                  responseId:
                    type: string
                    description: Use this field according to the endpoint schema.
                  modelStatus:
                    type: object
                    description: Use this field according to the endpoint schema.
                    properties:
                      modelStage:
                        type: string
                        description: Use this field according to the endpoint schema.
                      retirementTime:
                        type: string
                        description: Use this field according to the endpoint schema.
                      message:
                        type: string
                        description: Use this field according to the endpoint schema.
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: >
            curl
            https://api.deerapi.com/v1beta/models/gemini-2.5-flash:generateContent
            \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "contents": [
                  {
                    "role": "user",
                    "parts": [
                      {
                        "text": "Summarize the benefits of retry logic for production API clients."
                      }
                    ]
                  }
                ]
              }'
        - lang: Python
          label: requests
          source: >
            import os

            import requests


            url =
            "https://api.deerapi.com/v1beta/models/gemini-2.5-flash:generateContent"

            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }

            payload = {
              "contents": [
                {
                  "role": "user",
                  "parts": [
                    {
                      "text": "Summarize the benefits of retry logic for production API clients."
                    }
                  ]
                }
              ]
            }


            response = requests.post(url, headers=headers, json=payload)

            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/v1beta/models/gemini-2.5-flash:generateContent",
            {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "contents": [
                  {
                    "role": "user",
                    "parts": [
                      {
                        "text": "Summarize the benefits of retry logic for production API clients."
                      }
                    ]
                  }
                ]
              }),
            });


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use a DeerAPI API Key as a Bearer token.

````