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

# X402 Top Up

> Top up your Venice credit balance using a `PAYMENT-SIGNATURE` header (the legacy `X-402-Payment` and `X-PAYMENT` header names are also accepted). If the header is missing, the endpoint returns payment requirements.

This is the primary x402 payment endpoint. It currently returns Base and Solana USDC payment options in the `accepts` array. All inference endpoints (chat, image, audio, video) consume from the credit balance you establish here.



## OpenAPI

````yaml POST /x402/top-up
openapi: 3.0.0
info:
  description: The Venice.ai API.
  termsOfService: https://venice.ai/legal/tos
  title: Venice.ai API
  version: '20260616.154934'
  x-guidance: >-
    Venice.ai is an OpenAI-compatible inference API supporting text, image,
    audio, and video generation.


    **Authentication options:**

    - API Key: Use Bearer token in Authorization header

    - x402 Wallet: Use USDC credits via EVM or Solana wallet (no account
    required)


    **For x402 wallet access:**

    1. POST /x402/top-up without headers to get payment requirements

    2. Choose one of the returned Base or Solana payment options and sign a USDC
    payment using the x402 SDK

    3. POST /x402/top-up with PAYMENT-SIGNATURE header to add credits

    4. Call any inference endpoint with SIGN-IN-WITH-X header


    **Pricing:** Prepaid credits consumed per request. Check /models for
    available models and their capabilities.
servers:
  - url: https://api.venice.ai/api/v1
security:
  - BearerAuth: []
tags:
  - description: >-
      Generate speech/audio, transcribe audio, and manage asynchronous audio
      generation jobs.
    name: Audio
  - description: >-
      Given a list of messages comprising a conversation, the model will return
      a response. Supports multimodal inputs including text, images, audio
      (input_audio), and video (video_url) for compatible models.
    name: Chat
  - description: List and describe the various models available in the API.
    name: Models
  - description: Generate and manipulate images using AI models.
    name: Image
  - description: Generate videos using AI models.
    name: Video
  - description: List and retrieve character information for use in completions.
    name: Characters
  - description: >-
      Billing and usage analytics. **Beta**: This API is currently in beta and
      may be unstable. Endpoints, request/response schemas, and behavior may
      change without notice.
    name: Billing
  - description: Proxy JSON-RPC requests to blockchain nodes. Billed per credit.
    name: Crypto RPC
  - description: >-
      Wallet-based API access using the x402 protocol. No API key required —
      authenticate with an EVM or Solana wallet.


      **How it works:**

      1. **Authenticate** — Send a `SIGN-IN-WITH-X` header (base64-encoded
      signed SIWX payload) with any request. EVM wallets sign an EIP-4361 SIWE
      message; Solana wallets sign the Solana SIWX message with Ed25519. See the
      `siwx` security scheme for the exact format.

      2. **Top up** — `POST /x402/top-up` without a payment header returns an
      `accepts` array with Base and Solana USDC payment options. Choose one
      entry, sign it using the x402 SDK (`npm install x402`), and re-submit with
      the `PAYMENT-SIGNATURE` header (the legacy `X-402-Payment` and `X-PAYMENT`
      names are also accepted).

      3. **Use any endpoint** — All inference endpoints (chat, image, audio,
      video, embeddings) accept `siwx` as an alternative to `BearerAuth`.
      Charges are deducted from your USDC credit balance.

      4. **Monitor balance** — `GET /x402/balance/{walletAddress}` returns your
      current balance. The `X-Balance-Remaining` response header on inference
      calls also reports it.


      **Quick start (5 lines):**

      ```

      import { VeniceClient } from '@venice-ai/x402-client'

      const venice = new VeniceClient(process.env.WALLET_KEY)

      await venice.topUp(10) // $10 USDC on a supported x402 rail

      const res = await venice.chat({ model: 'zai-org-glm-5-1', messages: [{
      role: 'user', content: 'Hello!' }] })

      ```


      **Payment:** USDC on Base (chain ID 8453) or Solana mainnet. Minimum
      top-up: $5. Alternatively, stake DIEM tokens for daily credits (1 DIEM =
      $1/day).
    name: x402
externalDocs:
  description: Venice.ai API documentation
  url: https://docs.venice.ai
paths:
  /x402/top-up:
    post:
      tags:
        - x402
      summary: /api/v1/x402/top-up
      description: >-
        Top up your Venice credit balance using a `PAYMENT-SIGNATURE` header
        (the legacy `X-402-Payment` and `X-PAYMENT` header names are also
        accepted). If the header is missing, the endpoint returns payment
        requirements.


        This is the primary x402 payment endpoint. It currently returns Base and
        Solana USDC payment options in the `accepts` array. All inference
        endpoints (chat, image, audio, video) consume from the credit balance
        you establish here.
      operationId: topUpX402Balance
      parameters:
        - description: >-
            Signed x402 v2 payment payload (base64-encoded `PaymentPayload`)
            used to top up the wallet balance on a supported rail such as Base
            or Solana. The canonical header is `PAYMENT-SIGNATURE`; the
            `X-402-Payment` and `X-PAYMENT` names are also accepted for
            backwards compatibility. If no payment header is present, the
            endpoint returns the 402 payment requirements.
          in: header
          name: PAYMENT-SIGNATURE
          required: false
          schema:
            example: eyJ4NDAyVmVyc2lvbiI6MiwicGF5bG9hZCI6Ii4uLiJ9
            type: string
      requestBody:
        description: >-
          No JSON body required. Payment is sent via the X-402-Payment header.
          Send an empty POST to discover payment requirements.
        required: false
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        '200':
          description: Top-up completed successfully.
          headers:
            PAYMENT-RESPONSE:
              description: >-
                Base64-encoded x402 v2 settlement result (`{ success, network,
                payer, transaction }`).
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      walletAddress:
                        type: string
                        description: Wallet that received the credited balance.
                        example: 0xyour_wallet_address
                      amountCredited:
                        type: number
                        description: Amount credited to the wallet in USD.
                        example: 10
                      newBalance:
                        type: number
                        description: Updated wallet balance in USD after the top-up.
                        example: 22.5
                      paymentId:
                        type: string
                        description: Unique identifier for the x402 payment.
                        example: payment_01HZY8M4W4Y6QZ8B6Q4P0V3J2K
                    required:
                      - walletAddress
                      - amountCredited
                      - newBalance
                      - paymentId
                    additionalProperties: false
                required:
                  - success
                  - data
                additionalProperties: false
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Machine-readable x402 error code.
                    example: X402_INVALID_PAYMENT
                  message:
                    type: string
                    description: Human-readable description of the x402 failure.
                    example: Invalid payment header
                  details:
                    type: object
                    properties: {}
                    description: Optional structured details about the x402 error.
                    example:
                      reason: signature_mismatch
                required:
                  - error
                  - message
                additionalProperties: false
        '402':
          description: Payment information required before the top-up can be processed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  x402Version:
                    type: number
                    description: x402 protocol version.
                    example: 2
                  accepts:
                    type: array
                    items:
                      type: object
                      properties:
                        scheme:
                          type: string
                          enum:
                            - exact
                          description: x402 payment scheme.
                          example: exact
                        network:
                          type: string
                          description: >-
                            Payment network in CAIP-2 form (e.g. `eip155:8453`
                            for Base, `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`
                            for Solana mainnet).
                          example: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
                        amount:
                          type: string
                          description: >-
                            Minimum payment amount in base units (USDC has 6
                            decimals).
                          example: '5000000'
                        asset:
                          type: string
                          description: USDC token address or mint for the selected network.
                          example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                        payTo:
                          type: string
                          description: Receiver wallet address.
                          example: 8qUL23aSj7mDWdoLMXGHFvnVCT9wd7jXcysiekroADEL
                        maxTimeoutSeconds:
                          type: number
                          description: >-
                            Maximum time allowed for payment settlement, in
                            seconds.
                          example: 300
                        extra:
                          type: object
                          properties: {}
                          description: >-
                            Network-specific x402 metadata. Solana accepts
                            include a feePayer.
                          example:
                            name: USD Coin
                            version: '2'
                            feePayer: BFK9TLC3edb13K6v4YyH3DwPb5DSUpkWvb7XnqCL9b4F
                      required:
                        - scheme
                        - network
                        - amount
                        - asset
                        - payTo
                        - maxTimeoutSeconds
                      additionalProperties: false
                    description: Array of accepted payment options.
                required:
                  - x402Version
                  - accepts
                additionalProperties: false
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
        '500':
          description: An unknown error occurred
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Machine-readable x402 error code.
                    example: X402_INVALID_PAYMENT
                  message:
                    type: string
                    description: Human-readable description of the x402 failure.
                    example: Invalid payment header
                  details:
                    type: object
                    properties: {}
                    description: Optional structured details about the x402 error.
                    example:
                      reason: signature_mismatch
                required:
                  - error
                  - message
                additionalProperties: false
      security: []
components:
  schemas:
    StandardError:
      type: object
      properties:
        error:
          type: string
          description: A description of the error
      required:
        - error
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````