API Reference
API Reference
AZNP v2.1 API endpoint, query parameters, response headers, and the optional Base (EVM) EIP-191·EIP-712 wallet signature (identity, not billing).
Conversion Endpoint
GET https://aznp-proxy.kerberos79.workers.dev/?url={target_url}
🔑 Base (EVM) Wallet Signature (Optional Identity)
Signing is optional — it confirms request identity and lifts the rate limit. Base (EVM) uses EIP-191 personal_sign over 'x402:base:{timestamp}' or EIP-712 typed data (X402Auth):
x-wallet-addressBase (EVM) address (0x + 40 hex) — optional identityx-timestampUnix Timestamp (Seconds, within 5 mins) — optional identity (chain-agnostic)x-signatureEIP-191 personal_sign of 'x402:base:{timestamp}' or EIP-712 typed data (0x + 130 hex) — optional identityx-chain'base' — declares the chain for address & signature verificationx-sig-type'eip191' | 'eip712'. When omitted, EIP-191 is verified first, then EIP-712💳 Credit Top-up API (POST /v1/topup)
Submit your Base (EVM) wallet address and deposit transaction hash (tx_hash) after transferring $20 USDC or more (chain: base):
# Request
curl -X POST "https://aznp-proxy.kerberos79.workers.dev/v1/topup" \
-H "Content-Type: application/json" \
-d '{"wallet": "0x...BaseEVMAddress", "tx_hash": "0x...BaseTxHash", "chain": "base"}'
# Response (200 OK)
{
"success": true,
"chain": "base",
"wallet": "0x...BaseEVMAddress",
"deposited_usdc": 20.0,
"added_credits": 12000,
"total_allowed_requests": 12000
}
Query Parameters
| Parameter | Required | Type / Scope | Description |
|---|---|---|---|
url | Required | Required | Target web page URL (Required) |
mode | Optional | Free / Pro | auto (default) / summary (summary mode, Pro) |
max_tokens | Optional | Free | Truncate the output to N tokens (free) |
render | Optional | Pro | true → force dynamic JS rendering (Tier 3, Pro) |
format | Optional | Free | markdown (default) | json | toml | yaml | json-ld — all free |
fresh | Optional | Free | 1 → bypass cache & force refresh |
images | Optional | Free | 0 → drop images from the output |
Response Headers
X-AZNP-PlanExecution plan (free | pro | enterprise)X-AZNP-SourceConversion source (cloudflare-native | aznp-self | browser-rendering | openapi-compressed | cache | kv)X-AZNP-CacheCache status (HIT | MISS | BYPASS)X-AZNP-BypassSet to 'true' on 307 Redirect for files or Free plan OpenAPI requestsX-Token-ReductionEstimated token reduction % (e.g. 88%)X-Markdown-TokensOutput token count (estimated)X-RateLimit-RemainingRemaining credit request countPAYMENT-REQUIREDTop-up spec JSON returned on HTTP 402AI Agent Code Example — Base (EVM) (Node.js · viem)
// Base (EVM) EIP-191 / EIP-712 Signature & Call Example (Node.js — viem)
import { createWalletClient, http } from 'viem';
import { base } from 'viem/chains';
import { privateKeyToAccount } from 'viem/accounts';
// Agent EVM private key (0x + 32 bytes hex) — store securely in .env
const account = privateKeyToAccount('0xYOUR_BASE_PRIVATE_KEY'); // derives 0x + 40 hex address
const client = createWalletClient({
account,
chain: base, // Base L2 (chainId 8453)
transport: http('https://mainnet.base.org'),
});
async function callAZNPProxy(targetUrl) {
const timestamp = Math.floor(Date.now() / 1000).toString();
// EIP-191 (personal_sign) over "x402:base:{timestamp}" — chain-bound message
const signatureEip191 = await client.signMessage({
account,
message: `x402:base:${timestamp}`,
});
// EIP-712 (typed data) — X402Auth(string message, uint256 timestamp)
const signatureEip712 = await client.signTypedData({
account,
domain: { name: 'AZNP', version: '1', chainId: 8453 },
types: {
X402Auth: [
{ name: 'message', type: 'string' },
{ name: 'timestamp', type: 'uint256' },
],
},
primaryType: 'X402Auth',
message: { message: 'x402', timestamp: BigInt(timestamp) },
});
const endpointUrl = `https://aznp-proxy.kerberos79.workers.dev/?url=${encodeURIComponent(targetUrl)}&render=true`;
const response = await fetch(endpointUrl, {
method: 'GET',
headers: {
'x-wallet-address': account.address, // 0x + 40 hex (lowercase)
'x-timestamp': timestamp,
'x-signature': signatureEip191, // use signatureEip712 when 'x-sig-type: eip712'
'x-chain': 'base',
'x-sig-type': 'eip191', // or 'eip712'
},
});
if (response.status === 402) {
const errorData = await response.json();
console.error("402 Payment Required: Insufficient credits. Please top up.", errorData);
return null;
}
const markdown = await response.text();
console.log("Token reduction:", response.headers.get("X-Token-Reduction"));
console.log("Clean Markdown output:", markdown.slice(0, 200));
return markdown;
}
🤖 Programmatic Wallet & Auto-Topup Script (Node.js — viem)
// 1. Base (EVM) Wallet Generation (Node.js — viem)
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
// Create a new private key programmatically for an AI Agent
const agentPrivateKey = generatePrivateKey(); // 0x + 32 bytes hex
const agentAddress = privateKeyToAccount(agentPrivateKey); // 0x + 40 hex
console.log("Agent Address:", agentAddress);
console.log("Agent Private Key (Store securely in .env):", agentPrivateKey);
// 2. HTTP 402 Auto-Payment Handler Pattern
async function fetchWithAutoTopup(targetUrl) {
let res = await callAZNPProxy(targetUrl);
// Detect 402 Payment Required (Insufficient credits)
if (res && res.status === 402) {
const paymentInfo = await res.json();
console.warn("HTTP 402 Payment Required received. Executing automated USDC topup...");
// Step 2a: Send $20 USDC via Base SDK to receiver wallet
const txHash = await executeUsdcTransfer({
from: agentAddress,
toAddress: paymentInfo.receiver_wallet || "0x22E2076148c529981495c3C02A23DfB1D4f8Db9C",
amountUsdc: 20.0
});
// Step 2b: Submit transaction hash to AZNP credit topup endpoint
const topupRes = await fetch("https://aznp-proxy.kerberos79.workers.dev/v1/topup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ wallet: agentAddress, tx_hash: txHash, chain: "base" })
});
if (topupRes.ok) {
console.log("Auto-topup successful! Resuming original request...");
return await callAZNPProxy(targetUrl); // Retry request
}
}
return res;
}
Error Codes
Errors are returned as TOML with an [error] table (code + action_recommendation) by default, and as JSON when format=json is used.
| Status | code | action_recommendation |
|---|---|---|
| 400 | missing_url / invalid_url / unsupported_format / max_tokens_too_large / chain_mismatch | fix the parameter |
| 404 | not_found | use GET /?url=... or the endpoints above |
| 429 | rate_limited | wait Retry-After seconds |
| 502 | fetch_failed | check URL reachability and retry |
| 500 | internal_error | retry a limited number of times |
HTTP 402 is only returned by the credit system (POST /v1/topup) when credits are exhausted. Its body and PAYMENT-REQUIRED header remain JSON.