Step 1: Choose a Service

Pick the AI service you need. Each one accepts code and returns structured analysis.

  • /api/explain-code -- Plain-English code explanation
  • /api/debug-assist -- Bug detection and fix suggestions
  • /api/code-review -- Quality, style, and best-practice review
  • /api/security-audit -- Vulnerability scanning
  • /api/automation-script -- Generate automation scripts
  • /api/mcp-blueprint -- MCP server architecture blueprints
  • /api/read-url -- Fetch a URL and return clean readable text (flat $0.005)
  • /api/extract-document -- Extract key information from any document
  • /api/analyze-image -- Analyze images: objects, text, context
  • /api/summarize-session -- Summarize conversation transcripts
  • /api/summarize-content -- Summarize articles and long-form text

Step 2: Make the Request

Send a POST with your code. No auth headers needed.

curl -X POST https://api.24klabs.ai/api/explain-code \
  -H "Content-Type: application/json" \
  -d '{
    "code": "const add = (a, b) => a + b;",
    "language": "javascript",
    "tier": "quick"
  }'

Step 3: Handle the 402

Without payment, the server responds with a 402 Payment Required containing everything you need to pay.

# HTTP/1.1 402 Payment Required
# PAYMENT-REQUIRED: <base64 encoded PaymentRequired object>
# Decoded:
{
  "x402Version": 2,
  "accepts": [{
    "scheme": "exact",
    "network": "eip155:8453",
    "amount": "10000",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0xe73D86f185bE79a33b0318d881B71f2a24371114",
    "maxTimeoutSeconds": 60
    "scheme": "exact",
    "mimeType": "application/json"
  }
}

Step 4: Pay with USDC on Base L2

Transfer the exact USDC amount to the wallet address on Base (Coinbase L2). Gas fees are fractions of a cent. Your AI agent or wallet SDK handles this automatically via the x402 protocol.

Step 5: Retry with Receipt

Resend the same request with the payment receipt in the header.

curl -X POST https://api.24klabs.ai/api/explain-code \
  -H "Content-Type: application/json" \
  -H "PAYMENT-SIGNATURE: <base64 encoded PaymentPayload>" \
  -d '{
    "code": "const add = (a, b) => a + b;",
    "language": "javascript",
    "tier": "quick"
  }'

The server verifies the on-chain payment and returns your result. Done.


Free Demo Endpoint

Not ready to pay? Try the free demo endpoint -- no payment required, 5 requests per day.

curl -X POST https://api.24klabs.ai/api/demo/explain \
  -H "Content-Type: application/json" \
  -d '{
    "code": "print('hello world')",
    "language": "python",
    "tier": "quick"
  }'