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

# Generate an image synchronously

> Run a Gemini-native Nano Banana request and receive the complete result on the same connection.

Use this method when the caller can wait for the final Gemini response.

Select a model-specific size before choosing **Try it**. The shared schema
contains all family sizes; individual model guides define which values are
valid.

<Card title="Compare model limits" href="/en/models/image/nano-banana/comparison">
  Review price and resolution before sending a billable request.
</Card>


## OpenAPI

````yaml openapi.json POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: YingTu Nano Banana API
  version: 1.0.0
  description: >-
    Gemini-native synchronous and asynchronous image generation with the current
    YingTu Nano Banana model family.
servers:
  - url: https://api.yingtu.ai
    description: YingTu API
security: []
tags:
  - name: Synchronous generation
    description: Wait for a complete Gemini response in one HTTP request.
  - name: Asynchronous tasks
    description: >-
      Submit image work, then retrieve the task until it reaches a terminal
      state.
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - Synchronous generation
      summary: Generate an image synchronously
      description: >-
        Runs a Gemini-native image generation or editing request and returns the
        complete response on the same connection.
      operationId: generateImageSynchronously
      parameters:
        - $ref: '#/components/parameters/Model'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateContentRequest'
            examples:
              textToImage:
                summary: Generate a 2K landscape image
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            A quiet reading room at sunrise, editorial
                            photography
                  generationConfig:
                    responseModalities:
                      - TEXT
                      - IMAGE
                    imageConfig:
                      aspectRatio: '16:9'
                      imageSize: 2K
      responses:
        '200':
          description: Complete Gemini response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateContentResponse'
              examples:
                verifiedImageResult:
                  summary: Representative completed image response
                  value:
                    candidates:
                      - content:
                          role: model
                          parts:
                            - inlineData:
                                mimeType: image/jpeg
                                data: BASE64_IMAGE_DATA
                        finishReason: STOP
                        index: 0
                    usageMetadata:
                      promptTokenCount: 37
                      candidatesTokenCount: 1846
                      totalTokenCount: 1883
                      promptTokensDetails:
                        - modality: TEXT
                          tokenCount: 37
                      candidatesTokensDetails:
                        - modality: IMAGE
                          tokenCount: 1680
                    modelVersion: gemini-3.1-flash-image
                    responseId: response_example
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - BearerAuth: []
components:
  parameters:
    Model:
      name: model
      in: path
      required: true
      description: Current Nano Banana model ID.
      schema:
        $ref: '#/components/schemas/ModelId'
      example: gemini-3.1-flash-image
  schemas:
    GenerateContentRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          title: Prompt and input
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/RequestContent'
          description: Messages sent to the model.
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Optional Gemini tools. Availability depends on the selected image
            model.
        toolConfig:
          type: object
          additionalProperties: true
          description: Configuration for tools declared in tools.
        safetySettings:
          type: array
          items:
            $ref: '#/components/schemas/SafetySetting'
        systemInstruction:
          $ref: '#/components/schemas/RequestContent'
        cachedContent:
          type: string
          description: >-
            Optional cached content resource name when supported by the selected
            model.
        generationConfig:
          $ref: '#/components/schemas/GenerationConfig'
          title: Output settings
    GenerateContentResponse:
      type: object
      required:
        - candidates
      properties:
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/Candidate'
        usageMetadata:
          $ref: '#/components/schemas/UsageMetadata'
        modelVersion:
          type: string
          description: The model version that produced the response.
          example: gemini-3.1-flash-image
        responseId:
          type: string
          description: Provider response identifier.
          example: response_example
        createTime:
          type: string
          format: date-time
          description: Creation time when supplied by the selected model channel.
    ModelId:
      type: string
      enum:
        - gemini-2.5-flash-image
        - gemini-3.1-flash-lite-image
        - gemini-3.1-flash-image
        - gemini-3-pro-image
    RequestContent:
      type: object
      required:
        - parts
      properties:
        role:
          title: Role
          type: string
          enum:
            - user
            - model
          default: user
          description: Message sender. Use user for a new request.
        parts:
          title: Prompt or media
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/RequestPart'
          description: Prompt text and optional source media.
    SafetySetting:
      type: object
      required:
        - category
        - threshold
      properties:
        category:
          type: string
          enum:
            - HARM_CATEGORY_HATE_SPEECH
            - HARM_CATEGORY_SEXUALLY_EXPLICIT
            - HARM_CATEGORY_DANGEROUS_CONTENT
            - HARM_CATEGORY_HARASSMENT
            - HARM_CATEGORY_CIVIC_INTEGRITY
            - HARM_CATEGORY_JAILBREAK
        threshold:
          type: string
          enum:
            - HARM_BLOCK_THRESHOLD_UNSPECIFIED
            - BLOCK_LOW_AND_ABOVE
            - BLOCK_MEDIUM_AND_ABOVE
            - BLOCK_ONLY_HIGH
            - BLOCK_NONE
            - 'OFF'
    GenerationConfig:
      type: object
      properties:
        stopSequences:
          type: array
          maxItems: 5
          items:
            type: string
        responseMimeType:
          type: string
        responseSchema:
          type: object
          additionalProperties: true
        responseJsonSchema:
          type: object
          additionalProperties: true
        responseModalities:
          title: Response type
          type: array
          minItems: 1
          uniqueItems: true
          items:
            type: string
            enum:
              - TEXT
              - IMAGE
          example:
            - TEXT
            - IMAGE
          description: Include IMAGE to receive an image.
        candidateCount:
          title: Number of outputs
          type: integer
          enum:
            - 1
          description: Use one output.
        maxOutputTokens:
          type: integer
          minimum: 1
        temperature:
          type: number
        topP:
          type: number
        topK:
          type: number
        seed:
          type: integer
          format: int64
        presencePenalty:
          type: number
        frequencyPenalty:
          type: number
        responseLogprobs:
          type: boolean
        logprobs:
          type: integer
        enableEnhancedCivicAnswers:
          type: boolean
        mediaResolution:
          type: string
        thinkingConfig:
          $ref: '#/components/schemas/ThinkingConfig'
        speechConfig:
          type: object
          additionalProperties: true
        imageConfig:
          $ref: '#/components/schemas/ImageConfig'
    Candidate:
      type: object
      required:
        - content
      properties:
        content:
          $ref: '#/components/schemas/ResponseContent'
        finishReason:
          type: string
          example: STOP
        index:
          type: integer
          minimum: 0
          example: 0
    UsageMetadata:
      type: object
      properties:
        promptTokenCount:
          type: integer
          minimum: 0
        candidatesTokenCount:
          type: integer
          minimum: 0
        totalTokenCount:
          type: integer
          minimum: 0
        thoughtsTokenCount:
          type: integer
          minimum: 0
        promptTokensDetails:
          type: array
          items:
            $ref: '#/components/schemas/ModalityTokenCount'
        candidatesTokensDetails:
          type: array
          items:
            $ref: '#/components/schemas/ModalityTokenCount'
        serviceTier:
          type: string
        trafficType:
          type: string
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    RequestPart:
      description: Choose one Part type.
      oneOf:
        - $ref: '#/components/schemas/TextPart'
        - $ref: '#/components/schemas/InlineDataPart'
        - $ref: '#/components/schemas/FileDataPart'
        - $ref: '#/components/schemas/FunctionCallPart'
        - $ref: '#/components/schemas/FunctionResponsePart'
        - $ref: '#/components/schemas/ExecutableCodePart'
        - $ref: '#/components/schemas/CodeExecutionResultPart'
    ThinkingConfig:
      type: object
      properties:
        includeThoughts:
          type: boolean
        thinkingBudget:
          type: integer
        thinkingLevel:
          type: string
          enum:
            - minimal
            - high
      description: Thinking options when supported by the selected image model.
    ImageConfig:
      title: Image settings
      type: object
      properties:
        aspectRatio:
          title: Aspect ratio
          type: string
          enum:
            - '1:1'
            - '2:3'
            - '3:2'
            - '3:4'
            - '4:3'
            - '4:5'
            - '5:4'
            - '9:16'
            - '16:9'
            - '21:9'
          example: '1:1'
          description: Output shape.
        imageSize:
          title: Image size
          type: string
          enum:
            - 1K
            - 2K
            - 4K
          description: Model-specific and case-sensitive.
    ResponseContent:
      type: object
      required:
        - parts
      properties:
        role:
          type: string
          const: model
        parts:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ResponsePart'
    ModalityTokenCount:
      type: object
      required:
        - modality
        - tokenCount
      properties:
        modality:
          type: string
          example: IMAGE
        tokenCount:
          type: integer
          minimum: 0
    ErrorObject:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
          example: invalid_request_error
        code:
          type:
            - string
            - 'null'
    TextPart:
      title: Text prompt
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Prompt or edit instruction.
    InlineDataPart:
      title: Source image
      type: object
      required:
        - inlineData
      properties:
        inlineData:
          $ref: '#/components/schemas/InlineData'
    FileDataPart:
      title: File URI part
      type: object
      required:
        - fileData
      properties:
        fileData:
          $ref: '#/components/schemas/FileData'
    FunctionCallPart:
      title: Function call part
      type: object
      required:
        - functionCall
      properties:
        functionCall:
          $ref: '#/components/schemas/FunctionCall'
    FunctionResponsePart:
      title: Function response part
      type: object
      required:
        - functionResponse
      properties:
        functionResponse:
          $ref: '#/components/schemas/FunctionResponse'
    ExecutableCodePart:
      title: Executable code part
      type: object
      required:
        - executableCode
      properties:
        executableCode:
          $ref: '#/components/schemas/ExecutableCode'
    CodeExecutionResultPart:
      title: Code execution result part
      type: object
      required:
        - codeExecutionResult
      properties:
        codeExecutionResult:
          $ref: '#/components/schemas/CodeExecutionResult'
    ResponsePart:
      type: object
      properties:
        text:
          type: string
        inlineData:
          $ref: '#/components/schemas/InlineData'
        fileData:
          $ref: '#/components/schemas/FileData'
        functionCall:
          $ref: '#/components/schemas/FunctionCall'
        functionResponse:
          $ref: '#/components/schemas/FunctionResponse'
        executableCode:
          $ref: '#/components/schemas/ExecutableCode'
        codeExecutionResult:
          $ref: '#/components/schemas/CodeExecutionResult'
        thought:
          type: boolean
        thoughtSignature:
          type: string
          format: byte
        partMetadata:
          type: object
          additionalProperties: true
        mediaResolution:
          type: object
          additionalProperties: true
        videoMetadata:
          type: object
          additionalProperties: true
      description: >-
        A Gemini response Part. Part data fields are mutually exclusive in the
        Gemini protocol.
    InlineData:
      title: Inline image
      type: object
      required:
        - mimeType
        - data
      properties:
        mimeType:
          title: Image MIME type
          type: string
          enum:
            - image/png
            - image/jpeg
            - image/webp
          example: image/png
        data:
          title: Image Base64
          type: string
          description: Raw Base64 without a data URL prefix.
          example: BASE64_IMAGE_DATA
    FileData:
      type: object
      required:
        - fileUri
      properties:
        mimeType:
          type: string
          description: Optional IANA MIME type.
        fileUri:
          type: string
          description: URI of a Gemini File API resource.
    FunctionCall:
      type: object
      required:
        - name
        - args
      properties:
        id:
          type: string
        name:
          type: string
        args:
          type: object
          additionalProperties: true
    FunctionResponse:
      type: object
      required:
        - name
        - response
      properties:
        id:
          type: string
        name:
          type: string
        response:
          type: object
          additionalProperties: true
    ExecutableCode:
      type: object
      required:
        - language
        - code
      properties:
        language:
          type: string
        code:
          type: string
    CodeExecutionResult:
      type: object
      required:
        - outcome
        - output
      properties:
        outcome:
          type: string
        output:
          type: string
  responses:
    BadRequest:
      description: Invalid model, field, or parameter value
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid YingTu API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Rate limit exceeded
      headers:
        Retry-After:
          description: Seconds to wait before retrying when supplied.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ServerError:
      description: The request could not be completed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: YingTu API key.

````