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

# Retry a failed job



## OpenAPI

````yaml /openapi.yaml post /jobs/{id}/retry
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:
  /jobs/{id}/retry:
    post:
      tags:
        - Jobs
      summary: Retry a failed job
      operationId: retryJob
      parameters:
        - $ref: '#/components/parameters/JobId'
      responses:
        '200':
          description: The retried job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Job'
        '404':
          $ref: '#/components/responses/JobNotFound'
        '409':
          description: Job cannot be retried in its current state
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    JobId:
      name: id
      in: path
      required: true
      schema:
        type: string
        pattern: ^job_
      example: job_a1b2c3d4e5f6
  schemas:
    Job:
      type: object
      properties:
        id:
          type: string
          example: job_a1b2c3d4e5f6
        status:
          $ref: '#/components/schemas/JobStatus'
        tool:
          type: string
          example: image
        input:
          type: object
          description: The request body as submitted (model, prompt, ...)
        output:
          oneOf:
            - $ref: '#/components/schemas/JobOutput'
            - type: 'null'
        error:
          type:
            - object
            - 'null'
        progress_message:
          type:
            - string
            - 'null'
          example: stitching 3/8 (40%)
        progress:
          type:
            - number
            - 'null'
          description: Fraction 0..1
        progress_metadata:
          type:
            - object
            - 'null'
        estimated_duration_ms:
          type:
            - integer
            - 'null'
        estimated_cost_cents:
          type:
            - integer
            - 'null'
        actual_cost_cents:
          type:
            - integer
            - 'null'
        pricing:
          $ref: '#/components/schemas/JobPricing'
        provider:
          type:
            - string
            - 'null'
          example: fal
        provider_model:
          type:
            - string
            - 'null'
          example: fal:flux_schnell
        provider_status:
          type:
            - string
            - 'null'
          description: The provider's raw status string
        provider_job_id:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        started_at:
          type:
            - string
            - 'null'
          format: date-time
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
        urls:
          type: object
          description: Lifecycle URLs (present on creation responses)
          properties:
            self:
              type: string
            status:
              type: string
            refresh:
              type: string
            cancel:
              type: string
            retry:
              type: string
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
    JobStatus:
      type: string
      enum:
        - queued
        - submitting
        - running
        - completed
        - failed
        - cancelled
      description: |
        Lifecycle is `queued` then `submitting` then `running`, ending in a
        terminal status (`completed`, `failed`, or `cancelled`).
    JobOutput:
      type: object
      description: Canonical output envelope. Present only when the job is completed.
      properties:
        version:
          type: string
          const: v1
        outputs:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                description: Stable varg-hosted URL (s3.varg.ai)
              file_id:
                type: string
                description: The file record for this output — use with /files and /lineage
              media_type:
                type: string
                example: video/mp4
              size_bytes:
                type: integer
              thumbnail_url:
                type:
                  - string
                  - 'null'
    JobPricing:
      type: object
      description: Structured pricing. 1 credit = 1 cent = $0.01.
      properties:
        estimated:
          type:
            - integer
            - 'null'
          description: Reserved at creation (cents)
        actual:
          type:
            - integer
            - 'null'
          description: Charged at completion (cents). 0 for cache hits.
        billing:
          type:
            - string
            - 'null'
        cached:
          type:
            - boolean
            - 'null'
          description: true when the result came from cache (actual = 0)
        billed_units:
          type:
            - object
            - 'null'
          example:
            images: 1
        pricing_id:
          type:
            - string
            - 'null'
          description: The pinned pricing rule this job was charged under
  responses:
    JobNotFound:
      description: Unknown job (or not owned by the caller)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  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.

````