> ## 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.

# Get an asynchronous image task

> Retrieve task state and the final Gemini-native result with the asynchronous task endpoint.

The task is visible only to the YingTu account that created it. Poll while the
status is `queued` or `in_progress`.

On `completed`, scan `result.candidates[].content.parts[]` and use the returned
MIME. On `failed`, show `error.message`; do not expect a partial image result.


## OpenAPI

````yaml openapi.json GET /v1/tasks/{task_id}
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:
  /v1/tasks/{task_id}:
    get:
      tags:
        - Asynchronous tasks
      summary: Get an asynchronous image task
      description: >-
        Returns the current state and, after completion, the Gemini-native
        result for a task created by the authenticated YingTu account.
      operationId: getAsynchronousImageTask
      parameters:
        - name: task_id
          in: path
          required: true
          description: Task ID returned by asyncGenerateContent.
          schema:
            type: string
          example: task_01JY8K6M6B4YQ3R8H4T6V2Z1AB
      responses:
        '200':
          description: Current task state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
              examples:
                completed:
                  summary: Completed image task
                  value:
                    task_id: task_example
                    status: completed
                    progress: 100%
                    model: gemini-3.1-flash-image
                    created_at: 1788311383
                    started_at: 1788311384
                    completed_at: 1788311393
                    result:
                      candidates:
                        - content:
                            role: model
                            parts:
                              - inlineData:
                                  mimeType: image/jpeg
                                  data: BASE64_IMAGE_DATA
                          finishReason: STOP
                          index: 0
                      usageMetadata:
                        promptTokenCount: 37
                        candidatesTokenCount: 1533
                        totalTokenCount: 1570
                      modelVersion: gemini-3.1-flash-image
                      responseId: response_example
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Task not found for this account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - GoogleApiKey: []
        - BearerAuth: []
components:
  schemas:
    Task:
      type: object
      required:
        - task_id
        - model
        - status
        - progress
        - created_at
      properties:
        task_id:
          type: string
        model:
          $ref: '#/components/schemas/ModelId'
        status:
          type: string
          enum:
            - queued
            - in_progress
            - completed
            - failed
        progress:
          type: string
          example: 100%
        created_at:
          type: integer
          format: int64
        started_at:
          type: integer
          format: int64
        completed_at:
          type: integer
          format: int64
        result:
          $ref: '#/components/schemas/GenerateContentResponse'
        error:
          $ref: '#/components/schemas/TaskError'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ModelId:
      type: string
      enum:
        - gemini-2.5-flash-image
        - gemini-3.1-flash-lite-image
        - gemini-3.1-flash-image
        - gemini-3-pro-image
    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.
    TaskError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: Gemini upstream returned no image data
    ErrorObject:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
          example: invalid_request_error
        code:
          type:
            - string
            - 'null'
    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
    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
    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:
      type: object
      required:
        - mimeType
        - data
      properties:
        mimeType:
          type: string
          example: image/png
        data:
          type: string
          description: Base64-encoded image bytes.
          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:
    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:
    GoogleApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: Your YingTu API key in the Gemini-native header.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: Your YingTu API key as a bearer token.

````