Google Document Understanding API

Operations related to Document Understanding

OpenAPI Specification

google-document-understanding-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Google Books About Document Understanding API
  description: API for retrieving Bookshelf and Volume resources from Google Books
  version: 1.0.0
  contact:
    name: Google Books API
    url: https://developers.google.com/books
servers:
- url: https://www.googleapis.com/books/v1
  description: Google Books API v1
tags:
- name: Document Understanding
  description: Operations related to Document Understanding
paths:
  /files:
    post:
      tags:
      - Document Understanding
      summary: Google Upload File (Resumable)
      description: "Upload a video, PDF, audio, or other media file using resumable upload protocol. Use this for files larger than 20MB, \nvideos longer than approximately 1 minute, or when you want to reuse the file across multiple requests.\n"
      operationId: uploadFile
      parameters:
      - name: X-Goog-Upload-Protocol
        in: header
        required: true
        schema:
          type: string
          enum:
          - resumable
        description: Upload protocol type
      - name: X-Goog-Upload-Command
        in: header
        required: true
        schema:
          type: string
          enum:
          - start
          - upload, finalize
        description: Upload command (start for initiation, "upload, finalize" for data upload)
      - name: X-Goog-Upload-Header-Content-Length
        in: header
        required: false
        schema:
          type: integer
        description: Total size of the file in bytes (required for start command)
      - name: X-Goog-Upload-Header-Content-Type
        in: header
        required: false
        schema:
          type: string
        description: MIME type of the file (required for start command)
      - name: X-Goog-Upload-Offset
        in: header
        required: false
        schema:
          type: integer
        description: Byte offset for upload (required for upload command)
      - name: Content-Length
        in: header
        required: false
        schema:
          type: integer
        description: Size of the current chunk being uploaded
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FilesPostRequest'
          application/octet-stream:
            schema:
              $ref: '#/components/schemas/FilesPostRequest1'
      responses:
        '200':
          description: Upload initiated or completed successfully
          headers:
            x-goog-upload-url:
              description: URL for uploading file data (returned on start command)
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-microcks-operation:
        delay: 100
        dispatcher: FALLBACK
        dispatcherRules: SuccessExample
  /models/{model}:generateContent:
    post:
      tags:
      - Document Understanding
      summary: Google Generate Content
      description: "Generates text output from various inputs including text, images, video, audio, and PDF documents.\n\n**Document Understanding**: Process PDF documents up to 1000 pages using native vision to:\n- Analyze and interpret text, images, diagrams, charts, and tables\n- Extract information into structured output formats\n- Summarize and answer questions based on visual and textual elements\n- Transcribe document content (e.g., to HTML) preserving layouts and formatting\n- Process multiple PDFs in a single request (within context window limits)\n\n**Video Understanding**: Process videos to describe, segment, and extract information, answer questions, \nand refer to specific timestamps.\n\n**Audio Understanding**: Analyze and understand audio input to:\n- Transcribe speech to text with timestamps\n- Translate audio content\n- Detect and label different speakers (speaker diarization)\n- Detect emotion in speech and music\n- Analyze specific segments and provide timestamps\n- Describe, summarize, or answer questions about audio content\n\n**Image Input**: Combine text with images for multimodal understanding.\n"
      operationId: generateContent
      parameters:
      - name: model
        in: path
        required: true
        description: The model to use for generation
        schema:
          type: string
          enum:
          - gemini-2.5-flash
          - gemini-2.5-pro
          example: gemini-2.5-flash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateContentRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateContentResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-microcks-operation:
        delay: 100
        dispatcher: FALLBACK
        dispatcherRules: SuccessExample
components:
  schemas:
    PromptFeedback:
      type: object
      properties:
        blockReason:
          type: string
          enum:
          - BLOCK_REASON_UNSPECIFIED
          - SAFETY
          - OTHER
          description: Reason why prompt was blocked
        safetyRatings:
          type: array
          items:
            $ref: '#/components/schemas/SafetyRating'
          description: Safety ratings for the prompt
    Content:
      type: object
      properties:
        role:
          type: string
          enum:
          - user
          - model
          description: The role of the content producer (optional for single-turn, required for multi-turn)
        parts:
          type: array
          description: Ordered parts that constitute a single message
          items:
            $ref: '#/components/schemas/Part'
      required:
      - parts
    Candidate:
      type: object
      properties:
        content:
          $ref: '#/components/schemas/Content'
          description: Generated content
        finishReason:
          type: string
          enum:
          - FINISH_REASON_UNSPECIFIED
          - STOP
          - MAX_TOKENS
          - SAFETY
          - RECITATION
          - OTHER
          description: Reason why generation stopped
        index:
          type: integer
          description: Index of the candidate
        safetyRatings:
          type: array
          items:
            $ref: '#/components/schemas/SafetyRating'
          description: Safety ratings for the generated content
    ThinkingConfig:
      type: object
      description: Configuration for thinking mode in Gemini 2.5 models
      properties:
        thinkingBudget:
          type: integer
          description: Thinking budget, set to 0 to disable thinking
          minimum: 0
          default: null
    SafetyRating:
      type: object
      properties:
        category:
          type: string
          enum:
          - HARM_CATEGORY_UNSPECIFIED
          - HARM_CATEGORY_DEROGATORY
          - HARM_CATEGORY_TOXICITY
          - HARM_CATEGORY_VIOLENCE
          - HARM_CATEGORY_SEXUAL
          - HARM_CATEGORY_MEDICAL
          - HARM_CATEGORY_DANGEROUS
          - HARM_CATEGORY_HARASSMENT
          - HARM_CATEGORY_HATE_SPEECH
          - HARM_CATEGORY_SEXUALLY_EXPLICIT
          - HARM_CATEGORY_DANGEROUS_CONTENT
        probability:
          type: string
          enum:
          - HARM_PROBABILITY_UNSPECIFIED
          - NEGLIGIBLE
          - LOW
          - MEDIUM
          - HIGH
    FileUploadResponse:
      type: object
      properties:
        file:
          type: object
          properties:
            name:
              type: string
              description: Resource name of the file
              example: files/abc123
            display_name:
              type: string
              description: Display name of the file
            mime_type:
              type: string
              description: MIME type of the file
              example: video/mp4
            size_bytes:
              type: string
              description: Size of the file in bytes
            create_time:
              type: string
              format: date-time
              description: Creation timestamp
            update_time:
              type: string
              format: date-time
              description: Last update timestamp
            expiration_time:
              type: string
              format: date-time
              description: Expiration timestamp
            sha256_hash:
              type: string
              description: SHA-256 hash of the file
            uri:
              type: string
              description: URI to use in generateContent requests
              example: https://generativelanguage.googleapis.com/v1beta/files/abc123
            state:
              type: string
              enum:
              - STATE_UNSPECIFIED
              - PROCESSING
              - ACTIVE
              - FAILED
              description: Processing state of the file
            error:
              type: object
              description: Error details if state is FAILED
              properties:
                message:
                  type: string
    GenerationConfig:
      type: object
      description: Configuration options for model generation and outputs
      properties:
        stopSequences:
          type: array
          description: Set of character sequences that will stop output generation
          items:
            type: string
          maxItems: 5
        temperature:
          type: number
          format: float
          description: Controls randomness of output (default 1.0 for Gemini 3 models)
          minimum: 0.0
          maximum: 2.0
          default: 1.0
        topP:
          type: number
          format: float
          description: Maximum cumulative probability of tokens to consider
          minimum: 0.0
          maximum: 1.0
        topK:
          type: integer
          description: Maximum number of tokens to consider
          minimum: 1
        maxOutputTokens:
          type: integer
          description: Maximum number of tokens to generate
          minimum: 1
        thinkingConfig:
          $ref: '#/components/schemas/ThinkingConfig'
          description: Configuration for thinking mode (Gemini 2.5 models)
        response_mime_type:
          type: string
          description: MIME type for structured output (e.g., application/json)
          enum:
          - text/plain
          - application/json
          example: application/json
        response_schema:
          type: object
          description: JSON schema for structured output format
          additionalProperties: true
    FileData:
      type: object
      description: Reference to a file uploaded via the File API or a YouTube URL
      properties:
        mime_type:
          type: string
          description: MIME type of the file (optional for YouTube URLs)
          example: video/mp4
        file_uri:
          type: string
          description: URI of the file from File API or YouTube URL
          examples:
          - https://generativelanguage.googleapis.com/v1beta/files/abc123
          - https://www.youtube.com/watch?v=9hE5-98ZeCg
      required:
      - file_uri
    GenerateContentRequest:
      type: object
      required:
      - contents
      properties:
        contents:
          type: array
          description: The content of the current conversation with the model
          items:
            $ref: '#/components/schemas/Content'
        system_instruction:
          $ref: '#/components/schemas/Content'
          description: System instructions to guide model behavior
        generationConfig:
          $ref: '#/components/schemas/GenerationConfig'
          description: Configuration options for model generation
    FilesPostRequestFile:
      description: FilesPostRequestFile schema
      type: object
      properties:
        display_name:
          type: string
          description: Display name for the file
    UsageMetadata:
      type: object
      properties:
        promptTokenCount:
          type: integer
          description: Number of tokens in the prompt
        candidatesTokenCount:
          type: integer
          description: Number of tokens in generated candidates
        totalTokenCount:
          type: integer
          description: Total token count
    FilesPostRequest1:
      description: FilesPostRequest1 schema
      type: string
      format: binary
    GenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          description: Generated content candidates
          items:
            $ref: '#/components/schemas/Candidate'
        promptFeedback:
          $ref: '#/components/schemas/PromptFeedback'
          description: Feedback about the prompt
        usageMetadata:
          $ref: '#/components/schemas/UsageMetadata'
          description: Token usage information
    InlineData:
      type: object
      required:
      - mime_type
      - data
      properties:
        mime_type:
          type: string
          description: MIME type of the data
          enum:
          - image/jpeg
          - image/png
          - image/webp
          - video/mp4
          - video/mpeg
          - video/mov
          - video/avi
          - video/x-flv
          - video/mpg
          - video/webm
          - video/wmv
          - video/3gpp
          - audio/wav
          - audio/mp3
          - audio/aiff
          - audio/aac
          - audio/ogg
          - audio/flac
          - application/pdf
        data:
          type: string
          format: byte
          description: Base64 encoded data
    FilesPostRequest:
      description: FilesPostRequest schema
      type: object
      properties:
        file:
          $ref: '#/components/schemas/FilesPostRequestFile'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status code
            message:
              type: string
              description: Error message
            status:
              type: string
              description: Error status
    Part:
      type: object
      description: A part of the content, can be text, inline data, or file data
      oneOf:
      - type: object
        required:
        - text
        properties:
          text:
            type: string
            description: Text content
      - type: object
        required:
        - inline_data
        properties:
          inline_data:
            $ref: '#/components/schemas/InlineData'
      - type: object
        required:
        - file_data
        properties:
          file_data:
            $ref: '#/components/schemas/FileData'
          video_metadata:
            $ref: '#/components/schemas/VideoMetadata'
            description: Optional metadata for video processing (clipping, FPS)
    VideoMetadata:
      type: object
      description: Metadata for customizing video processing
      properties:
        start_offset:
          type: string
          description: Start time offset for video clipping (format like "1250s")
          pattern: ^\d+s$
          example: 1250s
        end_offset:
          type: string
          description: End time offset for video clipping (format like "1570s")
          pattern: ^\d+s$
          example: 1570s
        fps:
          type: number
          format: float
          description: Custom frame rate sampling (frames per second). Default is 1 FPS. Use <1 for long videos, >1 for rapidly changing visuals
          minimum: 0.1
          example: 5
  securitySchemes:
    OAuth2:
      type: oauth2
      description: OAuth 2.0 authentication for Google Books API
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.google.com/o/oauth2/v2/auth
          tokenUrl: https://oauth2.googleapis.com/token
          scopes:
            https://www.googleapis.com/auth/books: Manage your Google Books library