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

# Apply presets to a request body

> Merges one or more presets into a request body you intend to send to a
generation endpoint and returns the finished payload. The tool is inferred
from `payload.model`. Presets that cannot be applied (unknown, no mapping
for the model's tool, or dropped by the model's schema) are reported in
`rejected` instead of failing the call. Returns `200` when at least one
preset applied and `422` when none did; the `422` body then still has the
`payload`/`applied`/`rejected` shape. A `422` with an `error` envelope means
the model in `payload.model` is unknown. Auth is optional.




## OpenAPI

````yaml /openapi.yaml post /presets/apply
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: Folders
    description: Group files into folders and file generated output automatically
  - name: Lineage
    description: Resolve which job produced a file
  - name: Presets
    description: Browse and apply reusable parameter values — voices, styles
  - name: Templates
    description: Browse, publish, use and render community templates
  - name: Pricing
    description: Estimate costs and browse the price catalog
  - name: Billing
    description: Balance, usage, and transaction history
  - name: Analytics
    description: >-
      Spend, runs and files over time — summaries, time series, breakdowns,
      activity
  - name: Account
    description: Identity and API key management
paths:
  /presets/apply:
    post:
      tags:
        - Presets
      summary: Apply presets to a request body
      description: >
        Merges one or more presets into a request body you intend to send to a

        generation endpoint and returns the finished payload. The tool is
        inferred

        from `payload.model`. Presets that cannot be applied (unknown, no
        mapping

        for the model's tool, or dropped by the model's schema) are reported in

        `rejected` instead of failing the call. Returns `200` when at least one

        preset applied and `422` when none did; the `422` body then still has
        the

        `payload`/`applied`/`rejected` shape. A `422` with an `error` envelope
        means

        the model in `payload.model` is unknown. Auth is optional.
      operationId: applyPresets
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PresetApplyRequest'
            example:
              payload:
                model: eleven_multilingual_v2
                text: Hello world
              presets:
                - preset_5f4dcc3b5aa7
      responses:
        '200':
          description: At least one preset was applied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PresetApplyResponse'
              examples:
                applied:
                  value:
                    payload:
                      model: eleven_multilingual_v2
                      text: Hello world
                      voice: preset_5f4dcc3b5aa7
                    applied:
                      - preset_5f4dcc3b5aa7
                    rejected: []
        '400':
          description: >-
            Body is not a JSON object, `payload` is missing or not an object,
            `payload.model` is missing, or `presets` is empty
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: |
            Nothing was applied. The body is a `PresetApplyResponse` (with a
            non-empty `rejected` list), or an `ErrorResponse` with code
            `unknown_model` when `payload.model` is not in the catalogue.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/PresetApplyResponse'
                  - $ref: '#/components/schemas/ErrorResponse'
      security:
        - {}
        - bearerAuth: []
components:
  schemas:
    PresetApplyRequest:
      type: object
      required:
        - payload
        - presets
      properties:
        payload:
          type: object
          additionalProperties: true
          description: >-
            The request body you intend to send to a generation endpoint.
            `model` is required; the tool is inferred from it.
        presets:
          type: array
          minItems: 1
          items:
            type: string
          description: >-
            Preset ids to merge, applied in order. Non-string entries are
            ignored.
    PresetApplyResponse:
      type: object
      required:
        - payload
        - applied
        - rejected
      properties:
        payload:
          type: object
          additionalProperties: true
          description: The merged request body, ready to send to the generation endpoint.
        applied:
          type: array
          items:
            type: string
          description: Ids of the presets that were merged.
        rejected:
          type: array
          items:
            $ref: '#/components/schemas/PresetRejection'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
    PresetRejection:
      type: object
      required:
        - id
        - reason
        - message
      properties:
        id:
          type: string
        reason:
          type: string
          enum:
            - unknown_preset
            - incompatible
            - catalogue_error
            - not_accepted_by_model
          description: >
            `unknown_preset`: id not in the catalogue. `incompatible`: no
            mapping for

            the model's tool. `catalogue_error`: the preset's mapping data is
            broken.

            `not_accepted_by_model`: the model's schema would silently drop the
            value.
        message:
          type: string
        available_tools:
          type: array
          items:
            type: string
          description: Present for `incompatible`; the tools this preset can be applied to.
  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.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.