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

# Import a file by URL

> Register a file from a URL. varg-hosted URLs (`*.varg.ai`) are
registered without re-uploading; external URLs are streamed to varg
storage. SSRF-protected (private IPs and localhost are rejected).




## OpenAPI

````yaml /openapi.yaml post /files/import
openapi: 3.1.0
info:
  title: varg API
  version: 2.0.0
  description: |
    Unified REST API for AI media generation at `api.varg.ai/v2`.

    One API key, ~80 models across 8 providers, async jobs, stable output URLs
    on `s3.varg.ai`, files with lineage, and transparent credit billing
    (1 credit = 1 cent = $0.01).

    **The async job pattern:** every generation request returns `202 Accepted`
    with a job object (`status: queued`). Poll `GET /jobs/{id}` until the job
    reaches a terminal status (`completed`, `failed`, or `cancelled`), then read
    `output.outputs[0].url`. Alternatively, set `options.webhook_url` in the
    request to receive an HMAC-signed callback when the job finishes.
servers:
  - url: https://api.varg.ai/v2
security:
  - bearerAuth: []
tags:
  - name: Generation
    description: >-
      Create generation jobs (image, video, speech, music, transcription,
      ffmpeg, render, pipeline)
  - name: Tools
    description: Discover tools, their schemas, and call any tool generically
  - name: Jobs
    description: Poll and manage job lifecycle
  - name: Files
    description: Upload, import, probe, and manage files
  - name: Lineage
    description: Resolve which job produced a file
  - name: Pricing
    description: Estimate costs and browse the price catalog
  - name: Billing
    description: Balance, usage, and transaction history
  - name: Account
    description: Identity and API key management
paths:
  /files/import:
    post:
      tags:
        - Files
      summary: Import a file by URL
      description: |
        Register a file from a URL. varg-hosted URLs (`*.varg.ai`) are
        registered without re-uploading; external URLs are streamed to varg
        storage. SSRF-protected (private IPs and localhost are rejected).
      operationId: importFile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                filename:
                  type: string
                media_type:
                  type: string
                origin:
                  type: string
                  enum:
                    - upload
                    - generated
                  description: >-
                    Explicit provenance (defaults to `generated` for varg URLs,
                    `upload` for external)
                hash:
                  type: string
                  description: sha256 of the bytes for dedup (`sha256:<hex>` or bare hex)
                size:
                  type: integer
                metadata:
                  type: object
                  description: Client-measured metadata (width, height, duration_ms, ...)
            examples:
              external:
                summary: Import an external URL
                value:
                  url: https://example.com/photo.jpg
                  filename: photo.jpg
      responses:
        '200':
          description: File imported (or deduplicated)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
        '400':
          description: Missing/unsafe URL or invalid origin
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Fetch/store failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    FileUploadResponse:
      type: object
      properties:
        file_id:
          type: string
        url:
          type: string
          description: Stable varg-hosted URL
        hash:
          type:
            - string
            - 'null'
        size:
          type: integer
        media_type:
          type: string
        filename:
          type:
            - string
            - 'null'
        title:
          type:
            - string
            - 'null'
        subtitle:
          type:
            - string
            - 'null'
        metadata:
          type:
            - object
            - 'null'
        deduplicated:
          type: boolean
          description: true when an existing file with the same content was returned
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        varg API key (`varg_...`). Get one at [app.varg.ai](https://app.varg.ai)
        or run `bunx vargai login`. App sessions may alternatively send a
        Supabase JWT.

````