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

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# Generate Images

> Generate an image based on input parameters

**Authentication:** This endpoint accepts either a Bearer API key or a `SIGN-IN-WITH-X` header for x402 wallet-based authentication. The legacy `X-Sign-In-With-X` header is also accepted during migration. When using x402, a `402 Payment Required` response indicates insufficient balance and includes top-up instructions. A `401` response with code `X402_USER_NOT_ALLOWED` means the wallet's Venice account is banned or deleted, or the wallet's x402 credit account belongs to a different user.

## Sizing Options

Image models use model-specific sizing parameters:

* Pixel-based models accept `width` and `height`, for example `venice-sd35`.
* Aspect-ratio models accept `aspect_ratio`, for example `qwen-image-2`. The Qwen Image family — `qwen-image`, `qwen-image-3`, `qwen-image-3-pro`, `qwen-image-2-1-turbo`, and `qwen-image-2-1-pro` — **rejects** `width` and `height` with a `400`; use `aspect_ratio` for those.
* Resolution-tier models accept both `aspect_ratio` and `resolution`.

For example, `gpt-image-2`, `nano-banana-2`, and `nano-banana-pro` support `resolution` values of `1K`, `2K`, and `4K`:

```json theme={"system"}
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
```

The same resolution-tier sizing pattern also applies to Nano Banana models:

```json theme={"system"}
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
```

For models that accept aspect ratio but do not expose resolution tiers, send `aspect_ratio` without `resolution`:

```json theme={"system"}
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
```

For models that use direct pixel dimensions, send `width` and `height` instead:

```json theme={"system"}
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
```

Check [Image Models](https://docs.venice.ai/models/image.md) or the [Models endpoint](https://docs.venice.ai/api-reference/endpoint/models/list.md) for each model's supported sizing options before mixing sizing fields across models.

## Quality Tiers

Some models accept an optional `quality` parameter (`low`, `medium`, `high`) that trades visual fidelity for cost. Models that list `qualities` in `model_spec.constraints` from [`GET /models?type=image`](https://docs.venice.ai/api-reference/endpoint/models/list) accept only those values, and some support only a subset such as `low` and `medium`. Other models ignore the parameter.

```json theme={"system"}
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
```

When you omit `quality`, the model uses its default tier (`high` for `gpt-image-2`). Pricing depends on the combination of `resolution` and `quality` — the per-tier prices for `gpt-image-2` (1K/2K/4K × low/medium/high) are exposed under `model_spec.pricing.quality` in the [Models endpoint](https://docs.venice.ai/api-reference/endpoint/models/list.md) and listed on the [GPT Image 2 page](https://docs.venice.ai/models/gpt-image-2.md).

> [!NOTE]
>
> Quality-aware pricing is the default for all API and SDK callers — no opt-in header required. Requests that omit `quality` are billed at the model's default tier (`high` for `gpt-image-2`).

## Postman Collection

For additional examples, please see this [Postman Collection](https://www.postman.com/veniceai/workspace/venice-ai-workspace/folder/38652128-0adc004d-2edf-4b88-a3bb-0f868c791c9c?action=share\&source=copy-link\&creator=38652128\&ctx=documentation).

***


## OpenAPI

````yaml POST /image/generate
openapi: 3.0.0
info:
  description: The Venice.ai API.
  termsOfService: https://venice.ai/legal/tos
  title: Venice.ai API
  version: '20261130.171848'
  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 a prepaid x402 credit balance 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 a chat, image, audio or embeddings endpoint with SIGN-IN-WITH-X
    header (video and voice changer require an API key)


    **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: >-
      Create vector embeddings from text. `input` must be a string or an array
      of strings. Token arrays are not supported. LangChain OpenAIEmbeddings
      must set `check_embedding_ctx_length=False` to send text instead of
      tiktoken IDs.
    name: Embeddings
  - description: >-
      Evaluate a state against typed questions and get structured answers
      (yes/no probabilities, option picks with distributions, rubric scores).
      **Beta**: This API is currently in beta and may be unstable.
      Request/response schemas and behavior may change without notice.
    name: Decisions
  - 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 an inference endpoint** — Chat, image, audio and embeddings
      endpoints accept `siwx` as an alternative to `BearerAuth`; video and voice
      changer require `BearerAuth`. Charges are deducted from your x402 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-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.
    name: x402
externalDocs:
  description: Venice.ai API documentation
  url: https://docs.venice.ai
paths:
  /image/generate:
    post:
      tags:
        - Image
      summary: /api/v1/image/generate
      description: >-
        Generate an image based on input parameters


        **Authentication:** This endpoint accepts either a Bearer API key or a
        `SIGN-IN-WITH-X` header for x402 wallet-based authentication. The legacy
        `X-Sign-In-With-X` header is also accepted during migration. When using
        x402, a `402 Payment Required` response indicates insufficient balance
        and includes top-up instructions. A `401` response with code
        `X402_USER_NOT_ALLOWED` means the wallet's Venice account is banned or
        deleted, or the wallet's x402 credit account belongs to a different
        user.
      operationId: generateImage
      parameters:
        - description: >-
            Supported compression encodings (gzip, br). Only applied when
            return_binary is false.
          in: header
          name: Accept-Encoding
          required: false
          schema:
            example: gzip, br
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateImageRequest'
      responses:
        '200':
          description: Successfully generated image
          headers:
            X-Balance-Remaining:
              description: >-
                Remaining x402 credit balance in USD after this request (only
                present for x402 auth).
              required: false
              schema:
                type: string
                example: '4.230000'
            Content-Encoding:
              description: The encoding used to compress the response
              schema:
                enum:
                  - gzip
                  - br
                type: string
            x-venice-is-blurred:
              description: >-
                Indicates if the generated image is blurred. When Safe Venice is
                enabled, adult material will be returned blurred.
              required: false
              schema:
                type: boolean
            x-venice-is-content-violation:
              description: >-
                Indicates if the generated image does not meet Venice terms of
                service.
              required: false
              schema:
                type: boolean
            x-venice-content-violation-count:
              description: >-
                Number of requested variants omitted because the model provider
                explicitly rejected them under its content policy. Other
                moderation outcomes can still return blacked-out images flagged
                by `x-venice-is-content-violation`.
              required: false
              schema:
                minimum: 1
                type: integer
            x-venice-model-deprecation-warning:
              description: >-
                A warning that the model is scheduled for deprecation, or that
                the requested model was retired and its replacement served the
                request
              required: false
              schema:
                type: string
            x-venice-model-deprecation-date:
              description: >-
                The date the model is scheduled for deprecation, or the date the
                requested model was retired
              required: false
              schema:
                type: string
                format: date-time
            x-venice-deprecated:
              description: >-
                Present and set to "true" when the model is deprecated, or when
                the requested model was retired and its replacement served the
                request. Absent otherwise.
              required: false
              schema:
                type: string
                enum:
                  - 'true'
            x-venice-deprecated-replacement:
              description: >-
                Public API model ID clients should migrate to: the published
                replacement, or the model that served a request for a retired
                model. Absent when there is none.
              required: false
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  content_policy_violation_count:
                    type: integer
                    minimum: 1
                    description: >-
                      Number of requested variants omitted because the model
                      provider explicitly rejected them under its content
                      policy. Other moderation outcomes can still return
                      blacked-out images flagged by
                      `x-venice-is-content-violation`.
                    example: 1
                  id:
                    type: string
                    description: The ID of the request.
                    example: generate-image-1234567890
                  images:
                    type: array
                    items:
                      type: string
                    description: >-
                      Base64 encoded image data. A partial response can contain
                      fewer entries than requested.
                  request:
                    nullable: true
                    description: The original request data sent to the API.
                  timing:
                    type: object
                    properties:
                      inferenceDuration:
                        type: number
                        description: Duration of inference in milliseconds
                      inferencePreprocessingTime:
                        type: number
                        description: Duration of preprocessing in milliseconds
                      inferenceQueueTime:
                        type: number
                        description: Duration of queueing in milliseconds
                      total:
                        type: number
                        description: Total duration of the request in milliseconds
                    required:
                      - inferenceDuration
                      - inferencePreprocessingTime
                      - inferenceQueueTime
                      - total
                required:
                  - id
                  - images
                  - timing
            image/jpeg:
              schema:
                description: Raw image data when return_binary is true and format is jpeg
                format: binary
                type: string
            image/png:
              schema:
                description: Raw image data when return_binary is true and format is png
                format: binary
                type: string
            image/webp:
              schema:
                description: Raw image data when return_binary is true and format is webp
                format: binary
                type: string
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetailedError'
        '401':
          description: |-
            - Authentication failed
            - This model is only available to Pro users
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
        '402':
          description: >-
            Payment or balance required. Response varies by authentication
            state:


            **API Key users:** Standard error response with
            `INSUFFICIENT_BALANCE` code. Top up your Venice balance at
            venice.ai.


            **Unauthenticated x402 discovery:** Structured x402 response with
            `x402Version`, `resource`, `accepts`, and
            `extensions["sign-in-with-x"]`. The `accepts` array advertises Base
            and Solana payment requirements.


            **Authenticated x402 wallet users with insufficient credit:**
            Structured response with `PAYMENT_REQUIRED` code containing:

            - `topUpInstructions`: Step-by-step guide to top up via x402
            protocol

            - `supportedTokens` / `supportedChains`: Accepted payment methods

            - `siwxChallenge`: Fresh Sign-In-With-X challenge metadata


            A wallet that has never completed a top-up has no Venice account yet
            and receives this response with a balance of `0`. The first
            successful top-up creates the account.


            The `PAYMENT-REQUIRED` header also contains a base64-encoded x402
            protocol object with the payment requirements for programmatic
            discovery.
          headers:
            PAYMENT-REQUIRED:
              description: >-
                Base64-encoded JSON with x402 payment requirements. Present on
                x402 middleware 402 responses. Decode to choose and sign one
                accepted payment requirement programmatically.
              required: false
              schema:
                type: string
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/StandardError'
                  - $ref: '#/components/schemas/X402InferencePaymentRequired'
        '403':
          $ref: '#/components/responses/ApiKeyIpRestrictedError'
        '415':
          description: Invalid request content-type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
        '422':
          description: >-
            The prompt violates the content policy of Venice.ai or the model
            provider, or a style reference image exceeds the pixel limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageContentViolationError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
        '500':
          description: Inference processing failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
        '503':
          description: The model is at capacity. Please try again later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardError'
      security:
        - BearerAuth: []
        - siwx: []
components:
  schemas:
    GenerateImageRequest:
      type: object
      properties:
        anon_user_id:
          type: string
          minLength: 1
          maxLength: 128
          pattern: ^[\x20-\x7E]+$
          description: >-
            Optional identifier for the API customer's end user. Combined with
            the Venice user id when attributing the request to upstream
            providers. Distinct from the discarded OpenAI `user` field. Must be
            printable ASCII and must not contain `||`.
          example: end-user-123
        cfg_scale:
          type: number
          minimum: 0
          exclusiveMinimum: true
          maximum: 20
          description: >-
            CFG scale parameter. Higher values lead to more adherence to the
            prompt.
          example: 7.5
        embed_exif_metadata:
          type: boolean
          default: false
          description: Embed prompt generation information into the image's EXIF metadata.
          example: false
        format:
          type: string
          enum:
            - jpeg
            - png
            - webp
          default: webp
          description: >-
            The image format to return. WebP are smaller and optimized for web
            use. PNG are higher quality but larger in file size. 
          example: webp
        height:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          maximum: 4096
          default: 1024
          description: >-
            Height of the generated image, in pixels (max 4096). For models that
            list aspect ratios, width and height select the nearest aspect_ratio
            and a resolution tier (long edge above 1536 → 2K, above 3072 → 4K;
            the highest offered tier at or below that, otherwise the model
            default). An explicit aspect_ratio or resolution overrides only its
            own value. For models that render an exact canvas, each side must be
            at most 1280 before any model upscale.
          example: 1024
        hide_watermark:
          type: boolean
          default: false
          description: >-
            Whether to hide the Venice watermark. Venice may ignore this
            parameter for certain generated content.
          example: false
        inpaint:
          nullable: true
          description: >-
            This feature is deprecated and was disabled on May 19th, 2025. A
            revised in-painting API will be launched in the near future.
          deprecated: true
        lora_strength:
          type: integer
          minimum: 0
          maximum: 100
          description: >-
            Lora strength for the model. Only applies if the model uses
            additional Loras.
          example: 50
        model:
          type: string
          description: The model to use for image generation.
          example: grok-imagine-image
        negative_prompt:
          type: string
          maxLength: 7500
          description: >-
            A description of what should not be in the image. Character limit is
            model specific and is listed in the promptCharacterLimit constraint
            in the model list endpoint.
          example: Clouds, Rain, Snow
        prompt:
          type: string
          minLength: 1
          maxLength: 7500
          description: >-
            The description for the image. Character limit is model specific and
            is listed in the promptCharacterLimit setting in the model list
            endpoint.
          example: A beautiful sunset over a mountain range
        return_binary:
          type: boolean
          default: false
          description: Whether to return binary image data instead of base64.
          example: false
        variants:
          type: integer
          minimum: 1
          maximum: 4
          description: >-
            Number of images to generate (1–4). Only supported when
            return_binary is false. Variants the model provider explicitly
            rejects under its content policy are omitted from a successful
            partial response. Other moderation outcomes can still return
            blacked-out images; check `x-venice-is-content-violation`.
          example: 3
        safe_mode:
          type: boolean
          default: true
          description: >-
            Whether to blur images classified as adult content. Defaults to
            true. Set to false to receive unblurred output. No Pro subscription
            is required, and the mature filter setting in the Venice app does
            not affect this. The x-venice-is-blurred response header reports
            whether the returned image was blurred.
          example: false
        seed:
          type: integer
          minimum: -999999999
          maximum: 999999999
          default: 0
          description: >-
            Random seed for generation. If not provided, a random seed will be
            used.
          example: 123456789
        steps:
          type: integer
          default: 8
          description: >-
            Number of inference steps. This model does not support steps - this
            field is ignored.
          example: 8
        style_preset:
          type: string
          description: >-
            An image style to apply to the image. Visit
            https://docs.venice.ai/api-reference/endpoint/image/styles for more
            details.
          example: 3D Model
        aspect_ratio:
          type: string
          description: >-
            Aspect ratio (utilized by certain image models including Nano
            Banana). Examples: "1:1", "16:9".
          example: '1:1'
        resolution:
          type: string
          description: >-
            Resolution (utilized by certain image models including Nano Banana).
            Examples: "1K", "2K", "4K".
          example: 1K
        quality:
          type: string
          enum:
            - low
            - medium
            - high
          description: >-
            Output quality for supported models (e.g. GPT Image 2 / GPT Image 2
            Edit). Higher values can increase the final request charge. See the
            model list for supported options.
          example: high
        transparent_background:
          type: boolean
          description: >-
            Return the image with a transparent background (alpha channel). Only
            supported by models with `supportsTransparentBackground: true` in
            their constraints (see GET /api/v1/models), and requires `format`
            png or webp; otherwise the request is rejected. Omit or set to false
            to keep the model default background.
          example: false
        enable_web_search:
          type: boolean
          description: >-
            Enable web search for the image generation task. This will allow the
            model to use the latest information from the web to generate the
            image. Only supported by certain models. If web search is used,
            additional credits are getting charged.
          example: false
        disable_prompt_optimization_thinking:
          type: boolean
          description: >-
            Skip the model's prompt-optimization thinking step for faster
            generation. Only supported by models with
            `supportsOptimizePromptThinking`; ignored by others. Omit to use the
            model default.
          example: false
        enhance_prompt:
          type: boolean
          description: >-
            Rewrite the prompt before generation to add clarifying visual
            detail. Additional credits are charged when a rewrite is generated.
            Adds up to ~30 seconds before generation starts. When enhancement is
            applied, the final prompt is returned URL-encoded in the
            `x-venice-enhanced-prompt` response header. Defaults to false.
          example: false
        width:
          type: integer
          minimum: 0
          exclusiveMinimum: true
          maximum: 4096
          default: 1024
          description: >-
            Width of the generated image, in pixels (max 4096). For models that
            list aspect ratios, width and height select the nearest aspect_ratio
            and a resolution tier (long edge above 1536 → 2K, above 3072 → 4K;
            the highest offered tier at or below that, otherwise the model
            default). An explicit aspect_ratio or resolution overrides only its
            own value. For models that render an exact canvas, each side must be
            at most 1280 before any model upscale.
          example: 1024
        style_references:
          type: array
          items:
            type: object
            properties:
              image:
                anyOf:
                  - type: string
                  - type: string
                    format: uri
                description: >-
                  A style reference image as a base64-encoded string (raw or
                  data URI) or a URL starting with http:// or https://. Must be
                  less than 8MB.
                example: https://example.com/style-reference.png
              strength:
                type: number
                minimum: 0.1
                maximum: 1
                description: >-
                  How strongly the reference guides the output (0.1–1). Defaults
                  to 0.5. Ignored by models where supportsStyleReferenceStrength
                  is false.
                example: 0.5
            required:
              - image
            additionalProperties: false
          description: >-
            Style reference images that guide the aesthetic of the generated
            image. Only supported by models with `supportsStyleReferences: true`
            (see GET /api/v1/models for the per-model `maxStyleReferences`
            limit).
          example:
            - image: https://example.com/style-reference.png
              strength: 0.5
      required:
        - model
        - prompt
      additionalProperties: false
    DetailedError:
      type: object
      properties:
        details:
          type: object
          properties: {}
          description: Details about the incorrect input
          example:
            _errors: []
            field:
              _errors:
                - Field is required
        error:
          type: string
          description: A description of the error
      required:
        - error
    StandardError:
      type: object
      properties:
        error:
          type: string
          description: A description of the error
      required:
        - error
    X402InferencePaymentRequired:
      anyOf:
        - type: object
          properties:
            x402Version:
              type: number
              description: x402 protocol version.
              example: 2
            error:
              type: string
              description: Human-readable payment requirement message.
              example: Payment required
            resource:
              type: object
              properties:
                url:
                  type: string
                  description: Protected resource URL.
                  example: https://api.venice.ai/api/v1/chat/completions
                description:
                  type: string
                  description: Human-readable resource description.
                  example: Venice API
                mimeType:
                  type: string
                  description: Resource MIME type.
                  example: application/json
              required:
                - url
                - description
                - mimeType
              additionalProperties: false
            accepts:
              type: array
              items:
                type: object
                properties:
                  scheme:
                    type: string
                    enum:
                      - exact
                    description: x402 payment scheme.
                    example: exact
                  network:
                    type: string
                    description: >-
                      Payment network for this requirement in CAIP-2 form (e.g.
                      `eip155:8453` for Base,
                      `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` for Solana
                      mainnet).
                    example: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
                  asset:
                    type: string
                    description: USDC token address or mint for the selected network.
                    example: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
                  amount:
                    type: string
                    description: >-
                      Required payment amount in base units (USDC has 6
                      decimals).
                    example: '10000000'
                  payTo:
                    type: string
                    description: Receiver wallet address for the selected network.
                    example: 8qUL23aSj7mDWdoLMXGHFvnVCT9wd7jXcysiekroADEL
                  maxTimeoutSeconds:
                    type: number
                    description: Maximum time allowed for payment settlement.
                    example: 300
                  extra:
                    type: object
                    properties: {}
                    description: >-
                      Network-specific x402 metadata. Solana requirements
                      include a feePayer.
                    example:
                      name: USD Coin
                      version: '2'
                      feePayer: BFK9TLC3edb13K6v4YyH3DwPb5DSUpkWvb7XnqCL9b4F
                required:
                  - scheme
                  - network
                  - asset
                  - amount
                  - payTo
                  - maxTimeoutSeconds
                  - extra
                additionalProperties: false
              description: >-
                Protocol payment requirements. Clients should choose one entry,
                such as Base or Solana, and sign exactly that requirement.
            extensions:
              type: object
              properties: {}
              description: >-
                Protocol extensions. Inference 402 responses include
                `sign-in-with-x` with a SIWX challenge for wallet-credit
                authentication.
            authOptions:
              type: object
              properties:
                apiKey:
                  type: object
                  properties:
                    header:
                      type: string
                      description: API key authentication header format.
                      example: 'Authorization: Bearer YOUR_API_KEY'
                    getKey:
                      type: string
                      description: Where to create or manage API keys.
                      example: https://venice.ai/settings/api
                    docs:
                      type: string
                      description: API key documentation URL.
                      example: https://docs.venice.ai/api-reference
                  required:
                    - header
                    - getKey
                    - docs
                  additionalProperties: false
                x402Wallet:
                  type: object
                  properties:
                    header:
                      type: string
                      description: Header used for Sign-In-With-X wallet authentication.
                      example: SIGN-IN-WITH-X
                    legacyHeader:
                      type: string
                      description: Legacy Sign-In-With-X header accepted during migration.
                      example: X-Sign-In-With-X
                    topUp:
                      type: string
                      description: >-
                        Endpoint used to discover and submit x402 top-up
                        payments.
                      example: POST /api/v1/x402/top-up
                    docs:
                      type: string
                      description: x402 top-up API documentation URL.
                      example: >-
                        https://docs.venice.ai/api-reference/endpoint/x402/top-up
                  required:
                    - header
                    - legacyHeader
                    - topUp
                    - docs
                  additionalProperties: false
              required:
                - apiKey
                - x402Wallet
              additionalProperties: false
          required:
            - x402Version
            - resource
            - accepts
            - authOptions
          additionalProperties: false
          description: >-
            Returned when an inference request has no API key or wallet
            authentication. The JSON body includes x402 discovery requirements
            and authentication options.
        - type: object
          properties:
            error:
              type: string
              enum:
                - Payment required
              description: Error message indicating payment is required.
            code:
              type: string
              enum:
                - PAYMENT_REQUIRED
              description: Machine-readable error code.
            reason:
              type: string
              enum:
                - insufficient_balance
              description: Reason the x402-authenticated request could not proceed.
            message:
              type: string
              description: Human-readable context about the payment requirement.
              example: Insufficient x402 balance
            currentBalanceUsd:
              type: number
              description: Current x402 credit balance for the wallet.
              example: 0.01
            minimumBalanceUsd:
              type: number
              description: Minimum x402 credit balance required before the request can run.
              example: 0.1
            description:
              type: string
              description: Protected resource description.
              example: Venice API
            suggestedTopUpUsd:
              type: number
              description: Suggested amount to top up in USD.
              example: 10
            minimumTopUpUsd:
              type: number
              description: Minimum allowed top-up amount in USD.
              example: 5
            supportedTokens:
              type: array
              items:
                type: string
              description: List of supported token symbols for payment.
              example:
                - USDC
            supportedChains:
              type: array
              items:
                type: string
              description: List of supported top-up rails.
              example:
                - base
                - solana
            topUpInstructions:
              type: object
              properties:
                step1:
                  type: string
                  description: 'First step: get payment requirements.'
                  example: >-
                    POST /api/v1/x402/top-up with no payment header to get
                    payment requirements
                step2:
                  type: string
                  description: 'Second step: sign the payment.'
                  example: >-
                    Choose a payment option from accepts and sign a USDC
                    transfer authorization using the x402 SDK
                    (createPaymentHeader)
                step3:
                  type: string
                  description: 'Third step: submit the payment.'
                  example: >-
                    POST /api/v1/x402/top-up with the signed PAYMENT-SIGNATURE
                    header
                receiverWallet:
                  type: string
                  description: >-
                    Legacy Base receiver wallet address. Prefer the selected
                    accepts entry from /x402/top-up for network-specific payTo
                    values.
                  example: <RECEIVER_WALLET_ADDRESS>
                tokenAddress:
                  type: string
                  description: >-
                    Legacy Base USDC token address. Prefer the selected accepts
                    entry from /x402/top-up for network-specific assets.
                  example: <USDC_TOKEN_ADDRESS>
                tokenDecimals:
                  type: number
                  description: Token decimal places.
                  example: 6
                network:
                  type: string
                  description: >-
                    Legacy Base target network. Prefer the selected accepts
                    entry from /x402/top-up for network-specific values.
                  example: eip155:8453
                minimumAmountUsd:
                  type: number
                  description: Minimum top-up amount in USD.
                  example: 5
              required:
                - step1
                - step2
                - step3
                - receiverWallet
                - tokenAddress
                - tokenDecimals
                - network
                - minimumAmountUsd
              additionalProperties: false
            siwxChallenge:
              type: object
              properties:
                info:
                  type: object
                  properties:
                    domain:
                      type: string
                      description: Domain for the SIWX challenge.
                      example: api.venice.ai
                    uri:
                      type: string
                      description: Resource URI for the challenge.
                      example: https://api.venice.ai/api/v1/chat/completions
                    version:
                      type: string
                      description: SIWX version.
                      example: '1'
                    nonce:
                      type: string
                      description: >-
                        Server-generated nonce for replay protection: 32 hex
                        characters.
                      example: a1b2c3d4e5f67890a1b2c3d4e5f67890
                    issuedAt:
                      type: string
                      description: ISO timestamp when the challenge was issued.
                      example: '2026-04-09T12:00:00.000Z'
                    expirationTime:
                      type: string
                      description: ISO timestamp when the challenge expires.
                      example: '2026-04-09T12:05:00.000Z'
                    statement:
                      type: string
                      description: Human-readable statement for the signature.
                      example: Sign in to Venice AI
                  required:
                    - domain
                    - uri
                    - version
                    - nonce
                    - issuedAt
                    - expirationTime
                    - statement
                  additionalProperties: false
                supportedChains:
                  type: array
                  items:
                    type: object
                    properties:
                      chainId:
                        type: string
                        description: Supported chain identity.
                        example: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
                      type:
                        type: string
                        enum:
                          - eip191
                          - ed25519
                        description: >-
                          Signature algorithm: `eip191` for EVM wallets (EOAs
                          and smart contract wallets), `ed25519` for Solana.
                        example: ed25519
                    required:
                      - chainId
                      - type
                    additionalProperties: false
                  description: Supported SIWX chains and signature types.
                schema:
                  type: object
                  properties: {}
                  description: >-
                    JSON Schema of the proof the client sends in the
                    `SIGN-IN-WITH-X` header.
              required:
                - info
                - supportedChains
                - schema
              additionalProperties: false
          required:
            - error
            - code
            - reason
            - suggestedTopUpUsd
            - minimumTopUpUsd
            - supportedTokens
            - supportedChains
            - topUpInstructions
            - siwxChallenge
          additionalProperties: false
    ImageContentViolationError:
      type: object
      properties:
        error:
          type: string
          description: A description of the error
        suggested_prompt:
          type: string
          description: >-
            An optional provider-suggested replacement prompt that complies with
            content policy.
          example: A watercolor painting of a lighthouse on a rocky coast at sunset.
        recommended_model:
          type: string
          description: >-
            A model ID that can be used as an alternative when a recommendation
            is available.
          example: chroma
        retryable:
          type: boolean
          description: >-
            Present on every content-policy rejection: whether retrying the same
            request may succeed. True when the selected model's provider
            moderation is nondeterministic; false when the same request would be
            rejected again. Absent on other 422 errors, such as an input image
            that exceeds the pixel limit.
          example: true
      required:
        - error
    ApiKeyIpRestrictedError:
      type: object
      properties:
        error:
          type: string
          enum:
            - >-
              This API key is restricted to configured IP addresses, and this
              request's source IP is not allowed
          description: A description of the error
          example: >-
            This API key is restricted to configured IP addresses, and this
            request's source IP is not allowed
      required:
        - error
  responses:
    ApiKeyIpRestrictedError:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiKeyIpRestrictedError'
      description: >-
        This API key is restricted to configured IP addresses, and this
        request's source IP is not allowed
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http
    siwx:
      description: >-
        Wallet-based authentication using the x402 sign-in-with-x extension.
        Supports EVM wallets on Base (EIP-4361 SIWE, including EIP-1271 smart
        contract wallets) and Ed25519 wallets on Solana mainnet.


        **Header format:** Base64-encoded JSON proof with these fields:

        - `domain` — `api.venice.ai`

        - `address` — EVM or Solana wallet address

        - `uri` — URL of the requested resource

        - `version` — `"1"`

        - `chainId` — `"eip155:8453"` for Base or
        `"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"` for Solana

        - `type` — `"eip191"` for EVM wallets or `"ed25519"` for Solana

        - `nonce` — the `nonce` from the latest 402 challenge
        (`extensions["sign-in-with-x"].info.nonce`), or 32 random hex
        characters. Each nonce works once.

        - `issuedAt` — ISO 8601 time the proof was signed. Proofs older than 5
        minutes are rejected.

        - `expirationTime`, `notBefore`, `statement`, `resources` — optional

        - `signature` — signature over the message built from these fields: an
        EIP-4361 SIWE message for EVM (hex) or the Solana sign-in message
        (base58)


        Venice rebuilds the signed message from these fields, with the bare
        reference on its `Chain ID` line (`8453`,
        `5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`). Proofs from older clients that send
        the signed `message` itself are still accepted.


        **Example (TypeScript, viem):**

        ```

        import { privateKeyToAccount } from 'viem/accounts'

        import { createSiweMessage } from 'viem/siwe'


        const account = privateKeyToAccount(PRIVATE_KEY)

        const fields = { domain: 'api.venice.ai', address: account.address, uri:
        'https://api.venice.ai/api/v1/chat/completions', version: '1' as const,
        nonce: crypto.randomUUID().replace(/-/g, ''), issuedAt: new
        Date().toISOString(), statement: 'Sign in to Venice AI' }

        const message = createSiweMessage({ ...fields, chainId: 8453, issuedAt:
        new Date(fields.issuedAt) })

        const signature = await account.signMessage({ message })

        const header = btoa(JSON.stringify({ ...fields, chainId: 'eip155:8453',
        type: 'eip191', signature }))

        // Set header: SIGN-IN-WITH-X: <header>

        ```


        **SDK:** `npm install venice-x402-client` provides `VeniceClient` and
        `createAuthFetch` which handle this automatically.


        **Billing:** x402 users pay from a prepaid x402 credit balance. Top up
        via `POST /x402/top-up`. When balance is insufficient, endpoints return
        `402` with structured top-up instructions.
      in: header
      name: SIGN-IN-WITH-X
      type: apiKey

````

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