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

# Spend summary

> Totals for a range, the comparison period (previous period by default) and the current balance.

All analytics endpoints return `{ "data": ..., "meta": ... }`. `meta` carries the resolved range
(`from` inclusive, `to` exclusive, ISO 8601 UTC), `timezone`, the comparison period, applied `filters`,
`data_as_of`, `money_unit`, `time_basis` and `attribution_scope`.

Amounts are whole credits; fields ending in `_cents` are credits (1 credit = 1 cent). Charges are counted
when they were posted to the ledger. On team accounts, non-members only see their own identity
dimensions (`attribution_scope: self`); others collapse into "Other ..." groups.




## OpenAPI

````yaml /openapi.yaml get /analytics/summary
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:
  /analytics/summary:
    get:
      tags:
        - Analytics
      summary: Spend summary
      description: >
        Totals for a range, the comparison period (previous period by default)
        and the current balance.


        All analytics endpoints return `{ "data": ..., "meta": ... }`. `meta`
        carries the resolved range

        (`from` inclusive, `to` exclusive, ISO 8601 UTC), `timezone`, the
        comparison period, applied `filters`,

        `data_as_of`, `money_unit`, `time_basis` and `attribution_scope`.


        Amounts are whole credits; fields ending in `_cents` are credits (1
        credit = 1 cent). Charges are counted

        when they were posted to the ledger. On team accounts, non-members only
        see their own identity

        dimensions (`attribution_scope: self`); others collapse into "Other ..."
        groups.
      operationId: getAnalyticsSummary
      parameters:
        - $ref: '#/components/parameters/AnalyticsFrom'
        - $ref: '#/components/parameters/AnalyticsTo'
        - $ref: '#/components/parameters/AnalyticsTimezone'
        - $ref: '#/components/parameters/AnalyticsCompare'
        - $ref: '#/components/parameters/AnalyticsCompareFrom'
        - $ref: '#/components/parameters/AnalyticsCompareTo'
        - $ref: '#/components/parameters/AnalyticsTool'
        - $ref: '#/components/parameters/AnalyticsModel'
        - $ref: '#/components/parameters/AnalyticsWorkspaceId'
        - $ref: '#/components/parameters/AnalyticsApiKeyId'
        - $ref: '#/components/parameters/AnalyticsMemberId'
        - $ref: '#/components/parameters/AnalyticsCreator'
        - $ref: '#/components/parameters/AnalyticsSource'
        - $ref: '#/components/parameters/AnalyticsStatus'
        - $ref: '#/components/parameters/AnalyticsIncludeBalance'
      responses:
        '200':
          description: Result envelope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsSummaryResponse'
        '400':
          description: >-
            Invalid parameter (code `invalid_request`, `invalid_range`,
            `range_too_large`, `invalid_timezone`, `invalid_filter`,
            `unsupported_group_by`, ...)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          description: Analytics is temporarily unavailable (`analytics_unavailable`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    AnalyticsFrom:
      name: from
      in: query
      required: false
      description: >
        Range start, inclusive. `YYYY-MM-DD` (local midnight in `timezone`), a
        local date-time

        (`2026-09-01T09:30`), or an ISO 8601 instant with offset. Default: `to`
        minus 30 days.

        Ranges are limited to 366 days.
      schema:
        type: string
        maxLength: 40
      example: '2026-09-01'
    AnalyticsTo:
      name: to
      in: query
      required: false
      description: Range end, exclusive. Same formats as `from`. Default is now.
      schema:
        type: string
        maxLength: 40
      example: '2026-10-01'
    AnalyticsTimezone:
      name: timezone
      in: query
      required: false
      description: >-
        IANA timezone used for date-only bounds and calendar buckets. Default
        `UTC`.
      schema:
        type: string
        maxLength: 64
      example: Europe/Berlin
    AnalyticsCompare:
      name: compare
      in: query
      required: false
      description: >
        `previous_period` compares against the equal-length period right before
        `from`;

        `none` disables comparison. Default is `previous_period` on
        `/analytics/summary`

        and `none` elsewhere. Ignored when `compare_from`/`compare_to` are
        given.
      schema:
        type: string
        enum:
          - previous_period
          - none
    AnalyticsCompareFrom:
      name: compare_from
      in: query
      required: false
      description: Explicit comparison start. Must be sent together with `compare_to`.
      schema:
        type: string
        maxLength: 40
    AnalyticsCompareTo:
      name: compare_to
      in: query
      required: false
      description: >-
        Explicit comparison end, exclusive. Must be sent together with
        `compare_from`.
      schema:
        type: string
        maxLength: 40
    AnalyticsTool:
      name: tool
      in: query
      required: false
      description: >-
        Filter by capability. Comma-separated tool keys (`video`, `image`,
        `speech`, `music`, `render`, `pipeline`, ...) or `none`. Up to 50
        values.
      schema:
        type: string
        maxLength: 4000
      example: video,image
    AnalyticsModel:
      name: model
      in: query
      required: false
      description: Filter by model. Comma-separated model ids or `none`. Up to 50 values.
      schema:
        type: string
        maxLength: 4000
    AnalyticsWorkspaceId:
      name: workspace_id
      in: query
      required: false
      description: >-
        Filter by folder. Comma-separated folder ids or `none` (no folder). Up
        to 50 values.
      schema:
        type: string
        maxLength: 4000
    AnalyticsApiKeyId:
      name: api_key_id
      in: query
      required: false
      description: >-
        Filter by the API key that started the run. Comma-separated key ids or
        `none`. Up to 50 values.
      schema:
        type: string
        maxLength: 4000
    AnalyticsMemberId:
      name: member_id
      in: query
      required: false
      description: >-
        Filter by the person who started the run. Comma-separated user ids or
        `none`. Up to 50 values.
      schema:
        type: string
        maxLength: 4000
    AnalyticsCreator:
      name: creator
      in: query
      required: false
      description: >
        Filter by creator: `api_key:<id>` (a personal API key) or `member:<id>`
        (a person),

        comma-separated, or `none`. Up to 50 values.
      schema:
        type: string
        maxLength: 4000
    AnalyticsSource:
      name: source
      in: query
      required: false
      description: >
        Filter by how the run was started. Comma-separated values of `app` (a
        person in the web app),

        `api` (API key, SDK, CLI), `mcp` (an agent via MCP), `internal` (varg
        system keys), `unknown`.
      schema:
        type: string
        maxLength: 4000
      example: api,mcp
    AnalyticsStatus:
      name: status
      in: query
      required: false
      description: >
        Filter by the charged job's status. Comma-separated values of
        `completed`, `failed`,

        `cancelled`, `awaiting_confirmation`, `running`, `submitting`, `queued`,
        `unknown`.
      schema:
        type: string
        maxLength: 4000
    AnalyticsIncludeBalance:
      name: include_balance
      in: query
      required: false
      description: Include the current balance in the response. Default `true`.
      schema:
        type: string
        enum:
          - 'true'
          - 'false'
  schemas:
    AnalyticsSummaryResponse:
      type: object
      required:
        - data
        - meta
      properties:
        data:
          $ref: '#/components/schemas/AnalyticsSummary'
        meta:
          $ref: '#/components/schemas/AnalyticsMeta'
      example:
        data:
          spend_cents: 4210
          charges: 96
          jobs: 80
          runs: 61
          unsuccessful_spend_cents: 120
          unattributed_spend_cents: 0
          previous: null
          change: null
          balance: null
        meta:
          definition_version: '2026-09-28'
          from: '2026-09-20T00:00:00.000Z'
          to: '2026-10-20T00:00:00.000Z'
          timezone: UTC
          compare: null
          filters: {}
          data_as_of: '2026-10-20T10:00:00.000Z'
          money_unit: cent
          time_basis: posted_at
          attribution_scope: full
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: model_not_found
            message:
              type: string
              example: 'Unknown model: flux-shnell'
            details: {}
    AnalyticsSummary:
      allOf:
        - $ref: '#/components/schemas/AnalyticsTotals'
        - type: object
          required:
            - previous
            - change
            - balance
          properties:
            previous:
              description: Totals for the comparison period, or null.
              oneOf:
                - type: 'null'
                - allOf:
                    - $ref: '#/components/schemas/AnalyticsTotals'
                    - type: object
                      properties:
                        from:
                          type: string
                          format: date-time
                        to:
                          type: string
                          format: date-time
            change:
              type:
                - object
                - 'null'
              properties:
                spend_cents:
                  type: integer
                spend_pct:
                  type:
                    - number
                    - 'null'
                  description: Percent change; null when the previous period had no spend.
            balance:
              description: >-
                Null when `include_balance=false` or the balance could not be
                read.
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/AnalyticsBalance'
    AnalyticsMeta:
      type: object
      description: Metadata describing how the numbers were computed.
      required:
        - definition_version
        - data_as_of
        - money_unit
        - time_basis
        - attribution_scope
      properties:
        definition_version:
          type: string
          description: Changes whenever a metric's meaning changes.
          example: '2026-09-28'
        from:
          type: string
          format: date-time
          description: Resolved range start (inclusive).
        to:
          type: string
          format: date-time
          description: Resolved range end (exclusive).
        timezone:
          type: string
          example: UTC
        compare:
          type:
            - object
            - 'null'
          description: The comparison period, or null when none.
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        filters:
          type: object
          description: Filters applied, keyed by query parameter name.
          additionalProperties:
            type: array
            items:
              type: string
        data_as_of:
          type: string
          format: date-time
        money_unit:
          type: string
          enum:
            - cent
          description: Amounts are whole credits, in fields ending in `_cents`.
        time_basis:
          type: string
          enum:
            - posted_at
            - lifetime
            - created_at
          description: >-
            `posted_at` = when the ledger charge was posted; `created_at` = when
            a file was made.
        attribution_scope:
          type: string
          enum:
            - full
            - self
          description: '`self` means identity dimensions show only the caller''s own values.'
    AnalyticsTotals:
      type: object
      required:
        - spend_cents
        - charges
        - jobs
        - runs
        - unsuccessful_spend_cents
        - unattributed_spend_cents
      properties:
        spend_cents:
          type: integer
          description: Credits charged in range.
        charges:
          type: integer
        jobs:
          type: integer
        runs:
          type: integer
        unsuccessful_spend_cents:
          type: integer
          description: Credits charged on jobs that ended failed or cancelled.
        unattributed_spend_cents:
          type: integer
          description: Credits whose job can no longer be identified.
    AnalyticsBalance:
      type: object
      description: Current balance. Not affected by range or filters.
      required:
        - available_cents
        - total_cents
        - held_cents
        - subscription_cents
        - rollover_cents
        - onetime_cents
        - as_of
      properties:
        available_cents:
          type: integer
          description: Spendable now (total minus held).
        total_cents:
          type: integer
        held_cents:
          type: integer
          description: Held by running jobs.
        subscription_cents:
          type: integer
        subscription_expires_at:
          type:
            - string
            - 'null'
          format: date-time
        rollover_cents:
          type: integer
        rollover_expires_at:
          type:
            - string
            - 'null'
          format: date-time
        onetime_cents:
          type: integer
        as_of:
          type: string
          format: date-time
  responses:
    Unauthorized:
      description: Missing or invalid API key / JWT
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unauthorized:
              value:
                error:
                  code: unauthorized
                  message: Invalid or missing API key or JWT
  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.