Base URL

https://api.24klabs.ai

Endpoints

Public Endpoints

GET /health

Server health check

GET /services

List all available services and pricing

GET /stats

Platform usage statistics

GET /.well-known/x402.json

x402 payment discovery manifest

GET /discovery/resources

Service discovery for AI agents

Free Demo

POST /api/demo/explain

Free code explanation (rate limited, 5/day)

Paid Services (x402)

POST /api/explain-code

Plain-English code explanation

POST /api/debug-assist

Bug detection and fix suggestions

POST /api/code-review

Quality, style, and best-practice review

POST /api/security-audit

Vulnerability scanning and analysis

POST /api/automation-script

Generate automation scripts from descriptions

POST /api/mcp-blueprint

MCP server architecture blueprints

Request Body

All POST endpoints accept the same JSON body schema.

{
  "code": "string",         // Required. The code to analyze.
  "language": "string",     // Optional. Language hint (auto-detected if omitted).
  "context": "string",      // Optional. Additional context for the analysis.
  "tier": "quick" | "standard" | "pro"  // Required. Analysis depth.
}

Tiers map to different models and depths of analysis. Quick uses Haiku, Standard uses Sonnet, Pro uses Opus.

Response (200 OK)

{
  "service": "explain-code",
  "tier": "quick",
  "result": "...",            // The AI-generated analysis
  "model": "claude-3-haiku",
  "tokens_used": 1247,
  "request_id": "req_abc123"
}

402 Payment Required

Returned when a paid endpoint is called without a valid payment receipt.

{
  "error": "Payment Required",
  "price": "0.50",
  "currency": "USDC",
  "network": "base",
  "wallet": "0x...",
  "paymentMethods": ["x402"],
  "x402": {
    "version": 1,
    "scheme": "exact",
    "mimeType": "application/json"
  }
}

Authentication: x402 Payment Flow

24K Labs uses the x402 protocol. There are no API keys or OAuth tokens. The payment itself is the authentication.

  1. Send a request to any paid endpoint without payment.
  2. Receive a 402 response with price, wallet, and payment details.
  3. Transfer the exact USDC amount on Base L2 to the provided wallet.
  4. Resend the original request with the X-Payment-Receipt header containing the transaction hash.
  5. The server verifies the on-chain transaction and returns the result.

AI agents using x402-compatible SDKs handle this loop automatically.