LLM inference your agent can buy by itself.

No AgentRouter sign-up.

00 / MODEL CATALOG
curl -sS https://api.agentrouter.cc/v1/models
  1. 01OFFER
  2. 02WALLET
  3. 03BUY ONCE
  4. 04USE IT
AGENTROUTER / BASE SEPOLIA

Purchase and inference

Read the offer, choose one wallet, buy once, then use the returned bearer key.

Choose one wallet. Changing a tab updates the whole guide; it never sends a payment.

READ THE OFFER

Read the purchase offer

This unpaid request returns HTTP 402 with a PAYMENT-REQUIRED header and an empty body. It neither signs nor pays. The header contains standard-base64 x402 v2 JSON; your wallet client reads it in the next step.

Check the current offer before authorizing payment: exact, Base Sepolia (eip155:84532), USDC asset 0x036CbD53842c5426634e7929541eC2318f3dCF7e, amount 1000000 (1 test USDC), and the recipient. Stop if the terms differ from what you intend to buy. The quote is for access credit, not the price of one model request.

No AgentRouter account or proprietary recovery header is required. The wallet owner still needs to authorize wallet setup and spending.

01 / OFFER · HTTP 402
curl -sS -X POST https://api.agentrouter.cc/v1/purchase \
  -D - -o /dev/null
02

CHOOSE ONE WALLET

Prepare one wallet

Use the same wallet in the purchase step. These checks do not authorize a payment. Keep wallet/session output private.

The purchase command also uses jq to load the delivered key privately. Have at least 1 test USDC and inspect the offer's amount, network, asset and recipient. The wallet client handles signing; never paste a wallet private key into a prompt or this site.

Set up MetaMask

Tested with MetaMask Agent Wallet 7.1.0 in server-wallet mode and its official payment helper. Complete vendor setup. Set METAMASK_SKILL_DIR to that helper's metamask-agent-wallet directory. It needs Python 3 and mm on PATH.

Expect authenticated/initialized and eligible: true for the offer. Eligibility alone does not prove settlement.

METAMASK
mm doctor
mm wallet balance --testnet-chain-ids 84532 \
  --token-contracts 0x036CbD53842c5426634e7929541eC2318f3dCF7e
python3 "${METAMASK_SKILL_DIR:?set the official helper directory}/scripts/x402_pay.py" inspect \
  https://api.agentrouter.cc/v1/purchase --method POST
Set up MetaMask from scratch ↗Full MetaMask path · Markdown ↗
03

BUY ONCE

Buy once and keep the key

Run the block for your chosen wallet once, with the owner's spending approval. After buying, use the delivered key. Switching wallets is not another step and does not undo a purchase.

The command saves the full result in a new private directory and loads AGENTROUTER_KEY without displaying it. Keep the terminal open for inference. Do not run these commands with shell tracing, paste the result into model context, or put it in a served directory.

The client handles PAYMENT-SIGNATURE and the PAYMENT-RESPONSE receipt. If any command fails, times out, or delivery is uncertain, stop; do not rerun pay. Another invocation can create another purchase. Preserve the private response and receipt. These stock-client examples do not retain an optional recovery capability, so self-service lost-key recovery is not available for this flow. Never repay automatically to recover a key.

MetaMask's tested helper has no purchase-cap flag: inspect the current offer immediately before running pay --confirm. Its signature may authorize payment without another phone prompt.

Expect status: settled, the API body in resource, and the decoded settlement receipt.

METAMASK
umask 077
PURCHASE_DIR="$(mktemp -d "$HOME/agentrouter-purchase.XXXXXX")" &&
python3 "${METAMASK_SKILL_DIR:?set the official helper directory}/scripts/x402_pay.py" pay \
  https://api.agentrouter.cc/v1/purchase --method POST \
  --network eip155:84532 \
  --asset 0x036CbD53842c5426634e7929541eC2318f3dCF7e --confirm \
  >"$PURCHASE_DIR/result.json" 2>"$PURCHASE_DIR/error.log" &&
AGENTROUTER_KEY="$(jq -er '.resource.key | select(type == "string" and length > 0)' "$PURCHASE_DIR/result.json")" &&
export AGENTROUTER_KEY
Full MetaMask path · Markdown ↗
04

USE IT

Run OpenAI-compatible inference with a purchased key

Verify zai/glm-5.3 is offered with openai in the current catalog before spending. Set AGENTROUTER_KEY privately. Create one identity per intended request; retain it and the exact body for retries. Do not rerun uuidgen to bypass an uncertain result.

Purchased keys do not support streaming. HTTP 200 returns an OpenAI-compatible completion. Replays return request status, not the original completion. HTTP 401 means an invalid key; 402 means allowance exhausted. Do not create a fresh identity after an uncertain charge.

ARRIVAL · CHAT COMPLETIONS
REQUEST_ID=$(uuidgen)

curl -sS https://api.agentrouter.cc/v1/chat/completions \
  -H "Authorization: Bearer ${AGENTROUTER_KEY:?set your key privately}" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "zai/glm-5.3",
    "max_tokens": 512,
    "reasoning_effort": "low",
    "stream": false,
    "messages": [{ "role": "user", "content": "Reply with exactly OK." }]
  }'

Machine-readable purchase flow

Read the purchase offer

This unpaid request returns HTTP 402 with a PAYMENT-REQUIRED header and an empty body. It neither signs nor pays. The header contains standard-base64 x402 v2 JSON; your wallet client reads it in the next step.

Check the current offer before authorizing payment: exact, Base Sepolia (eip155:84532), USDC asset 0x036CbD53842c5426634e7929541eC2318f3dCF7e, amount 1000000 (1 test USDC), and the recipient. Stop if the terms differ from what you intend to buy. The quote is for access credit, not the price of one model request.

No AgentRouter account or proprietary recovery header is required. The wallet owner still needs to authorize wallet setup and spending.

curl -sS -X POST https://api.agentrouter.cc/v1/purchase \
  -D - -o /dev/null

HTTP 402 Payment Required, Cache-Control: no-store, a PAYMENT-REQUIRED header and an empty body. The decoded header has x402Version: 2, resource.url: /v1/purchase and an accepts array. Each option supplies its network, asset, amount, recipient and EIP-3009 signing metadata. A 402 error without that header is not a usable offer.

Prepare one wallet

Use the same wallet in the purchase step. These checks do not authorize a payment. Keep wallet/session output private.

The purchase command also uses jq to load the delivered key privately. Have at least 1 test USDC and inspect the offer's amount, network, asset and recipient. The wallet client handles signing; never paste a wallet private key into a prompt or this site.

Set up MetaMask

Tested with MetaMask Agent Wallet 7.1.0 in server-wallet mode and its official payment helper. Complete vendor setup. Set METAMASK_SKILL_DIR to that helper's metamask-agent-wallet directory. It needs Python 3 and mm on PATH.

Expect authenticated/initialized and eligible: true for the offer. Eligibility alone does not prove settlement.

mm doctor
mm wallet balance --testnet-chain-ids 84532 \
  --token-contracts 0x036CbD53842c5426634e7929541eC2318f3dCF7e
python3 "${METAMASK_SKILL_DIR:?set the official helper directory}/scripts/x402_pay.py" inspect \
  https://api.agentrouter.cc/v1/purchase --method POST
Full MetaMask path · Markdown ↗

These readiness checks should not return a bearer key or settle a payment.

Compare the decoded offer with step 1. Do not proceed on missing funds, an unavailable wallet, an unsupported offer or unapproved terms. New wallet versions need their own compatibility check.

Buy once and keep the key

Run the block for your chosen wallet once, with the owner's spending approval. After buying, use the delivered key. Switching wallets is not another step and does not undo a purchase.

The command saves the full result in a new private directory and loads AGENTROUTER_KEY without displaying it. Keep the terminal open for inference. Do not run these commands with shell tracing, paste the result into model context, or put it in a served directory.

The client handles PAYMENT-SIGNATURE and the PAYMENT-RESPONSE receipt. If any command fails, times out, or delivery is uncertain, stop; do not rerun pay. Another invocation can create another purchase. Preserve the private response and receipt. These stock-client examples do not retain an optional recovery capability, so self-service lost-key recovery is not available for this flow. Never repay automatically to recover a key.

MetaMask's tested helper has no purchase-cap flag: inspect the current offer immediately before running pay --confirm. Its signature may authorize payment without another phone prompt.

Expect status: settled, the API body in resource, and the decoded settlement receipt.

umask 077
PURCHASE_DIR="$(mktemp -d "$HOME/agentrouter-purchase.XXXXXX")" &&
python3 "${METAMASK_SKILL_DIR:?set the official helper directory}/scripts/x402_pay.py" pay \
  https://api.agentrouter.cc/v1/purchase --method POST \
  --network eip155:84532 \
  --asset 0x036CbD53842c5426634e7929541eC2318f3dCF7e --confirm \
  >"$PURCHASE_DIR/result.json" 2>"$PURCHASE_DIR/error.log" &&
AGENTROUTER_KEY="$(jq -er '.resource.key | select(type == "string" and length > 0)' "$PURCHASE_DIR/result.json")" &&
export AGENTROUTER_KEY
Full MetaMask path · Markdown ↗

The API returns HTTP 200 with key, usage and PAYMENT-RESPONSE.

The commands export the opaque bearer key without printing it. A zero client exit code alone is insufficient: the response must contain the key and confirmed payment receipt. Keep the original response privately. Inspect the transaction through the Base Sepolia explorer, without sharing the bearer key.

Run OpenAI-compatible inference with a purchased key

Verify zai/glm-5.3 is offered with openai in the current catalog before spending. Set AGENTROUTER_KEY privately. Create one identity per intended request; retain it and the exact body for retries. Do not rerun uuidgen to bypass an uncertain result.

Purchased keys do not support streaming. HTTP 200 returns an OpenAI-compatible completion. Replays return request status, not the original completion. HTTP 401 means an invalid key; 402 means allowance exhausted. Do not create a fresh identity after an uncertain charge.

REQUEST_ID=$(uuidgen)

curl -sS https://api.agentrouter.cc/v1/chat/completions \
  -H "Authorization: Bearer ${AGENTROUTER_KEY:?set your key privately}" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "zai/glm-5.3",
    "max_tokens": 512,
    "reasoning_effort": "low",
    "stream": false,
    "messages": [{ "role": "user", "content": "Reply with exactly OK." }]
  }'

Expected inference result

HTTP 200 returns an OpenAI-compatible completion, with the answer in choices[0].message.content and token counts in usage. The tested request returned OK; model output can vary. A 200 status with no visible answer is not proof of a useful reply. Keep the request identity if the result is uncertain; do not create a new billable request automatically.

COMPATIBILITY

Point your existing SDK at us.

Use the interface your agent already speaks.

OPENAI · /v1/chat/completions
REQUEST_ID=$(uuidgen)

curl -sS https://api.agentrouter.cc/v1/chat/completions \
  -H "Authorization: Bearer ${AGENTROUTER_KEY:?set your key privately}" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "zai/glm-5.3",
    "max_tokens": 512,
    "reasoning_effort": "low",
    "stream": false,
    "messages": [{ "role": "user", "content": "Reply with exactly OK." }]
  }'
ANTHROPIC · /v1/messages
REQUEST_ID=$(uuidgen)

curl -sS https://api.agentrouter.cc/v1/messages \
  -H "Authorization: Bearer ${AGENTROUTER_KEY:?set your key privately}" \
  -H "Idempotency-Key: $REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -H 'anthropic-version: 2023-06-01' \
  -d '{
    "model": "zai/glm-5.3",
    "max_tokens": 512,
    "stream": false,
    "messages": [{ "role": "user", "content": "Reply with exactly OK." }]
  }'
CONTINUE

Read the surface you need.