Onchain Router Base Mainnet
Base mainnet · USDC paymentsAny verified wallet can pay. Check every payment term and set a local spending limit before signing.

Developer documentation

Make your first paid AI request

Choose a text, image, or speech route, check its payment limit, send one request on Base mainnet, and save the result and receipt.

Page tools

This guide uses an official x402 buyer and the Base mainnet payment contract. It spends USDC. Any wallet may pay after successful x402 verification, and no payer registration is required. The browser buyer included in this repository is an optional local integration tool; it is not a separate public service.

1. Prepare a dedicated wallet

For tighter wallet isolation, create a separate wallet account and fund it with only the small amount of Base mainnet USDC needed for the next few requests. You may also need a small amount of Ether (ETH) on Base if the selected payment path does not pay the network fee for you. The service does not require a separate wallet, but we strongly recommend one.

Never use a primary or highly funded wallet.

2. Choose what to call

The five paid routes are Chat Completions, Messages, Image Generations, Text to Speech, and Speech to Text. The Models, Pricing, Voices, and Balance routes are free. Read the endpoint overview, then use GET /v1/models to select a compatible model and GET /v1/pricing to inspect its current billing unit.

Gemini currently serves text and image generation. ElevenLabs Flash v2.5 serves MP3 text to speech, and Scribe v2 serves MP3 speech to text. The API contract remains provider-neutral as the catalog expands.

3. Use an official x402 buyer

Call the official Hypertext Transfer Protocol Secure (HTTPS) address with an x402 buyer that supports the Base mainnet upto payment scheme and Permit2 authorization. Start with GET /v1/models, then send the request below to POST /v1/chat/completions. The first unpaid response has HTTP status 402. The buyer checks the payment terms, signs locally, and retries the identical request.

Coinbase Developer Platform and Google Vertex credentials belong only on the server. A buyer never supplies, receives, or stores them. Stop immediately if any website or agent asks you for a Coinbase secret, Google credential, wallet seed phrase, or wallet private key.

4. Send production-shaped JSON

Chat Completions is a simple first request. Choose any compatible text model from GET /v1/models; the same payment lifecycle also protects the image and speech routes.

json
{
  "model": "gemini-3.6-flash",
  "messages": [
    {
      "role": "user",
      "content": "Explain in two short sentences why the sky appears blue."
    }
  ],
  "max_tokens": 1024,
  "stream": false
}

Preview the payment in your buyer. Confirm that the request uses Base mainnet (eip155:8453), official Base USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), recipient 0xA7660dea6AadCc87CbB5e79ccd262d391e61dE5d, the upto payment scheme, and a maximum no higher than your local spending limit.

5. Authorize and read the result

Confirm the wallet signatures. Your first request may require both a request-specific Permit2 authorization and a USDC permit. These signatures approve a limited transfer. They never require you to reveal your private key.

Read the visible answer from:

text
choices[0].message.content

Then record the receipt ID, authorized maximum, actual settled amount, and BaseScan transaction. Do not publish the prompt, completion, receipt access token, or payment payload.

Common results

  • A finish_reason value of "stop" means the answer completed normally.
  • A finish_reason value of "length" means the model reached the output limit. Increase max_tokens, obtain a new quote, and retry.
  • HTTP status 402 is the expected response before payment authorization.
  • An empty_provider_response error is not charged. The model used the available output budget without returning visible text.
  • If the provider or payment result is unknown, recover the existing request before starting a new one.
Reviewed 2026-08-21Catalog d815ab0e8989

Search guides, endpoint references, models, and pricing.