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

# Buy credits with a machine payment

> POST with your API key (X-Api-Key or Authorization: Bearer) and no payment header to receive a 402 that carries an x402 v2 `PAYMENT-REQUIRED` header (USDC on Base / Solana) and a Stripe MPP `WWW-Authenticate: Payment` challenge (Shared Payment Token cards, Tempo USDC). Pay with either, then retry the same request with `PAYMENT-SIGNATURE` (x402) or `Payment-Authorization` (MPP). Credits are granted on settlement and never expire; a replayed settlement returns the same 200 with `duplicate: true`. Without an API key and without a payment header the 402 carries the x402 challenge only (this is what the x402 Bazaar indexes); a paid retry without an API key is refused with 401 before anything settles.



## OpenAPI

````yaml /openapi.json post /api/v1/credits/topup/{credits}
openapi: 3.1.0
info:
  title: VidGuy API
  version: 1.0.0
  description: >-
    Make videos, snacks, carousels, images and audio with VidGuy, and post them
    to your connected accounts. Authenticate with a `vf_live_` key as a Bearer
    token.
servers:
  - url: https://www.vidguy.ai
security:
  - ApiKeyAuth: []
tags:
  - name: Jobs
  - name: Credits
  - name: Brands
  - name: Snacks and memes
  - name: Videos
  - name: Carousels and slides
  - name: Images and video models
  - name: Characters
  - name: Editing
  - name: Assets
  - name: Audio
  - name: Social posting
paths:
  /api/v1/credits/topup/{credits}:
    post:
      tags:
        - Credits
      summary: Buy credits with a machine payment
      description: >-
        POST with your API key (X-Api-Key or Authorization: Bearer) and no
        payment header to receive a 402 that carries an x402 v2
        `PAYMENT-REQUIRED` header (USDC on Base / Solana) and a Stripe MPP
        `WWW-Authenticate: Payment` challenge (Shared Payment Token cards, Tempo
        USDC). Pay with either, then retry the same request with
        `PAYMENT-SIGNATURE` (x402) or `Payment-Authorization` (MPP). Credits are
        granted on settlement and never expire; a replayed settlement returns
        the same 200 with `duplicate: true`. Without an API key and without a
        payment header the 402 carries the x402 challenge only (this is what the
        x402 Bazaar indexes); a paid retry without an API key is refused with
        401 before anything settles.
      operationId: topupCredits
      parameters:
        - schema:
            type: string
            enum:
              - '10'
              - '50'
              - '100'
              - '250'
              - '500'
              - '1000'
            example: '10'
          required: true
          name: credits
          in: path
      responses:
        '200':
          description: Credits granted after settlement.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditsTopupResponse'
        '401':
          description: Invalid API key, or a payment header sent without one.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required (challenge headers) or payment rejected.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditsTopupPaymentRequired'
        '403':
          description: Plan cannot top up by machine payment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Unsupported top-up size.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: >-
            The account's daily spend cap is reached (only when one is set;
            there is none by default).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: No payment rail enabled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreditsTopupResponse:
      type: object
      properties:
        creditsAdded:
          type: integer
        newBalance:
          type: integer
        duplicate:
          type: boolean
        rail:
          type: string
          enum:
            - x402
            - mpp
        reference:
          type: string
        network:
          type: string
        method:
          type: string
        amountUsd:
          type: string
      required:
        - creditsAdded
        - newBalance
        - duplicate
        - rail
        - reference
        - amountUsd
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          example: Invalid request
        message:
          type: string
        details:
          type: object
          additionalProperties: {}
      required:
        - error
    CreditsTopupPaymentRequired:
      type: object
      properties:
        error:
          type: string
          enum:
            - payment_required
        credits:
          type: integer
        amountUsd:
          type: string
        rails:
          type: array
          items:
            type: string
            enum:
              - x402
              - mpp
        message:
          type: string
        register:
          type: string
          format: uri
          description: >-
            Present when the request carried no API key: where an agent account
            is created.
        offers:
          type: array
          items:
            $ref: '#/components/schemas/CreditsTopupOffer'
      required:
        - error
        - credits
        - amountUsd
        - rails
        - message
        - offers
    CreditsTopupOffer:
      type: object
      properties:
        credits:
          type: integer
        priceUsd:
          type: string
        url:
          type: string
      required:
        - credits
        - priceUsd
        - url
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: 'Send your API key in the Authorization header: `Bearer vf_live_...`'

````

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