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

# Create Gemini upload session

> Create a short-lived upload instruction for a local file. Send the file bytes directly to the returned `upload.url`, using the returned method and headers, then complete the upload through LinkModel.

This workflow is only for Google Gemini models that support native `fileData` input. The resulting file URI cannot be used with OpenAI, Anthropic, compatibility, image-generation, or video-generation endpoints.




## OpenAPI

````yaml /openapi/files/_create-upload-session.yaml post /files/upload-sessions
openapi: 3.0.3
info:
  title: Create Gemini upload session
  version: 1.0.0
  description: >-
    Create a pre-signed upload session for a file that will be referenced by a
    Gemini-native request.
servers:
  - url: https://api.linkmodel.ai/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Gemini
  - name: files
paths:
  /files/upload-sessions:
    post:
      tags:
        - Gemini
        - files
      summary: Create Gemini upload session
      description: >
        Create a short-lived upload instruction for a local file. Send the file
        bytes directly to the returned `upload.url`, using the returned method
        and headers, then complete the upload through LinkModel.


        This workflow is only for Google Gemini models that support native
        `fileData` input. The resulting file URI cannot be used with OpenAI,
        Anthropic, compatibility, image-generation, or video-generation
        endpoints.
      operationId: create-gemini-upload-session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - filename
                - mime_type
                - size_bytes
                - md5sum
                - purpose
              properties:
                filename:
                  type: string
                  description: >-
                    Use a portable ASCII basename containing letters, numbers,
                    dots, hyphens, or underscores. Avoid spaces and non-ASCII
                    punctuation because the filename becomes part of the Gemini
                    file URI.
                  example: sample.mp4
                mime_type:
                  type: string
                  example: video/mp4
                size_bytes:
                  type: integer
                  format: int64
                  minimum: 1
                  description: Exact file size in bytes.
                  example: 35077
                md5sum:
                  type: string
                  description: Lowercase hexadecimal MD5 checksum of the complete file.
                  example: 4c7576b35abc9bde1a09a6a257937eb3
                purpose:
                  type: string
                  enum:
                    - vision
                  example: vision
      responses:
        '200':
          description: Upload session and pre-signed object-storage instruction.
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - data
                properties:
                  code:
                    type: integer
                    enum:
                      - 0
                    example: 0
                  data:
                    type: object
                    required:
                      - file_id
                      - status
                      - expires_at
                      - upload
                    properties:
                      file_id:
                        type: string
                        example: file_example123
                      status:
                        type: string
                        example: pending_upload
                      expires_at:
                        type: integer
                        format: int64
                        description: Unix timestamp when the file resource expires.
                        example: 1783666435
                      upload:
                        type: object
                        required:
                          - url
                          - method
                          - headers
                          - expires_at
                        properties:
                          url:
                            type: string
                            format: uri
                            description: >-
                              Short-lived pre-signed upload URL. Treat it as
                              sensitive.
                          method:
                            type: string
                            enum:
                              - PUT
                          headers:
                            type: object
                            description: Headers and values to use for the direct upload.
                            additionalProperties:
                              type: string
                            example:
                              Content-Type: video/mp4
                              Content-MD5: base64-md5-from-the-server
                          expires_at:
                            type: integer
                            format: int64
                            description: >-
                              Unix timestamp when the upload instruction
                              expires.
                            example: 1783659235
        '400':
          description: Invalid filename, MIME type, size, checksum, or purpose.
        '401':
          description: Missing or invalid LinkModel API key.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````