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

# Upload file

> Upload a file (image, audio, video) for use in generation requests. Returns a stable URL you can pass to `files[].url`.

Max file size: 50MB. Pass `X-Content-Hash` for deduplication — if a file with the same hash already exists, the existing file is returned without re-uploading.




## OpenAPI

````yaml /openapi.yaml post /files
openapi: 3.1.0
info:
  title: Varg Gateway API
  version: 0.1.0
  description: >-
    Unified REST API for AI generation (video, image, speech, music) at
    api.varg.ai
servers:
  - url: https://api.varg.ai/v1
security:
  - bearerAuth: []
tags:
  - name: Generation
    description: Create AI-generated content
  - name: Jobs
    description: Manage and monitor generation jobs
  - name: Files
    description: Upload files for use in generation
  - name: Reference
    description: Available models and voices
  - name: Media Processing
    description: FFmpeg-powered video utilities (trim, resize, probe, custom commands)
  - name: Account
    description: Account info, balance, and usage
paths:
  /files:
    post:
      tags:
        - Files
      summary: Upload file
      description: >
        Upload a file (image, audio, video) for use in generation requests.
        Returns a stable URL you can pass to `files[].url`.


        Max file size: 50MB. Pass `X-Content-Hash` for deduplication — if a file
        with the same hash already exists, the existing file is returned without
        re-uploading.
      operationId: uploadFile
      parameters:
        - name: X-Content-Hash
          in: header
          required: false
          schema:
            type: string
          description: SHA-256 hash of the file content, used for deduplication
          example: sha256:abc123def456...
      requestBody:
        required: true
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '200':
          description: File uploaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
        '401':
          $ref: '#/components/responses/AuthError'
        '413':
          description: File too large (max 50MB)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    FileUploadResponse:
      type: object
      required:
        - file_id
        - url
        - hash
        - size
        - media_type
        - deduplicated
      properties:
        file_id:
          type: string
          description: Unique file identifier
          example: file_abc123
        url:
          type: string
          format: uri
          description: Stable URL for the uploaded file
          example: https://s3.varg.ai/u/user_xxx/abc123.jpg
        hash:
          type: string
          description: SHA-256 hash of the file content
          example: sha256:abc123def456...
        size:
          type: number
          description: File size in bytes
          example: 102400
        media_type:
          type: string
          description: Detected MIME type
          example: image/jpeg
        deduplicated:
          type: boolean
          description: True if an existing file with the same hash was returned
          example: false
    ErrorResponse:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code
          example: ValidationError
        message:
          type: string
          description: Human-readable error description
          example: prompt is required
        field:
          type: string
          description: The field that caused the error, if applicable
          example: prompt
        provider:
          type: string
          description: The upstream provider that returned the error, if applicable
          example: fal
        statusCode:
          type: number
          description: HTTP status code
          example: 400
  responses:
    AuthError:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: AuthError
            message: Invalid API key
            statusCode: 401
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: InternalError
            message: An unexpected error occurred
            statusCode: 500
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: varg_xxx
      description: |
        API key from [varg.ai/dashboard](https://varg.ai/dashboard).

        Pass as `Authorization: Bearer varg_xxx`.

````