AI Router · CLI · MCPCheapest eligible quotes before you create

402 runbook

Read the header before you recover.

HTTP 402 alone is not enough. OfflineCreator uses two shapes: a legacy insufficient-credits JSON body without PAYMENT-REQUIRED, and an x402 challenge that includes the PAYMENT-REQUIRED header with machine-payable USDC terms.

Identity
API key first
Legacy path
Stripe / Studio
Agent path
Wallet settle

Branch on the exact 402 shape

Follow the sequence in order. Each step is a bounded operator action—not a promise that every deployment has x402 enabled.

  1. 01

    Capture status and headers

    Preserve HTTP 402, the JSON code/body, and whether PAYMENT-REQUIRED is present. Do not retry paid work until that envelope is recorded.

  2. 02

    Legacy INSUFFICIENT_CREDITS

    If there is no PAYMENT-REQUIRED header, treat it as a human funding signal. Top up via Studio pricing or Stripe Checkout, then re-read balance.

  3. 03

    x402 PAYMENT-REQUIRED

    If PAYMENT-REQUIRED is present, the body carries payment terms and usually a locked quote. A configured stdio MCP or CLI wallet can sign and retry with PAYMENT-SIGNATURE.

  4. 04

    Confirm before the next job

    After settlement or human purchase, run balance (or get_credits) again. Retry only when the operator chooses to continue.

  • IdentityAPI key first

    x402 is payment, not login. Bearer or OAuth auth still runs before any challenge.

  • Legacy pathStripe / Studio

    JSON INSUFFICIENT_CREDITS without PAYMENT-REQUIRED means fund the account in a browser.

  • Agent pathWallet settle

    PAYMENT-REQUIRED means sign USDC locally under the session spend cap.

Runbook FAQ

Can I ignore the body and only look at status 402?

No. Both rails can return 402. The PAYMENT-REQUIRED header is the reliable branch: present means x402 challenge; absent with INSUFFICIENT_CREDITS means human Stripe or Studio top-up.

What if x402 is disabled on the deployment?

The API keeps the classic JSON insufficient-credits 402. Configure Stripe or Studio top-up, or enable the rail on the server before expecting wallet settlement.

Keep payment decisions explicit.

Humans stay on Stripe. Agents settle only with a local wallet and a spend cap. When the shape is unclear, start with the PAYMENT-REQUIRED diagnosis runbook.