Home / API docs / Code Debugging API
AI Utilities

Code Debugging API

POST /api/debug-code $0.01 per call USDC on Base · x402

LLM CODE DEBUGGING — POST {code, error} and get a diagnosis: what is wrong, the root cause, and a concrete fix with corrected code. Paste the failing snippet plus the error message or stack trace; any language, up to 20,000 chars combined. Optional {language} and {context} ('happens only on the second call'). Fast cheap LLM under the hood. Want deterministic no-AI lint instead? POST /api/lint/:language ($0.002).

Parameters

NameInDescription
codebodyrequiredThe failing code snippet (required)
errorbodyError message, stack trace, or a description of the wrong behavior
languagebodyOptional language hint, e.g. python, javascript, elixir
contextbodyOptional extra context: what you expected, when it happens, what you tried

Example request

curl -X POST "https://api.webbersites.com/api/debug-code" \
  -H "Content-Type: application/json" \
  -d '{"code":"def total(xs):\n  sum = 0\n  for x in xs:\n    sum =+ x\n  return sum","error":"total([1,2,3]) returns 3 instead of 6","language":"python"}'
# first call returns 402 + payment requirements; an x402 client pays and retries automatically

Example response

{
    "diagnosis": "The accumulator is never incremented — `sum =+ x` assigns +x instead of adding.",
    "root_cause": "`=+` is assignment with unary plus, not the `+=` compound operator, so each iteration overwrites sum with x.",
    "fix": "Use `sum += x` inside the loop.",
    "fixed_code": "def total(xs):\n  total = 0\n  for x in xs:\n    total += x\n  return total",
    "confidence": "high",
    "model": "gemini-2.5-flash-lite"
}
MCP tool: post_debug_code — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.

How payment works

There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.