P

Python Code Validator · Repair

by Python Code Validator

POSTBase

$0.03

per call · USD Coin on Base

Return corrected Python for code that fails those checks: the fix is applied and re-checked, and only returned when it holds.

Endpoint

POST https://api.statemind.ai/v1/x402/repair

1

Calls / 30d

1

Unique payers / 30d

Aug 16

Last called

exact

Payment scheme

Call this service

TypeScript · @x402/fetch
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay("https://api.statemind.ai/v1/x402/repair", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "code": "def bitcount(n):\n    count = 0\n    while n:\n        n ^= n - 1\n    return count\n",
    "options": {
      "examples": "assert bitcount(127) == 7\nassert bitcount(0) == 0"
    }
  }),
});
const data = await res.json();
cURL
curl -X POST \
  "https://api.statemind.ai/v1/x402/repair" \
  -H "Content-Type: application/json" \
  -d '{"code":"def bitcount(n):\n    count = 0\n    while n:\n        n ^= n - 1\n    return count\n","options":{"examples":"assert bitcount(127) == 7\nassert bitcount(0) == 0"}}' \
  -H "X-PAYMENT: <signed x402 payment>"

Example response

{
  "diagnostics": [
    {
      "code": "python:example-mismatch",
      "message": "assert bitcount(127) == 7 failed: the code loops forever",
      "severity": "error"
    }
  ],
  "fixed_code": "def bitcount(n):\n    count = 0\n    while n:\n        n &= n - 1\n        count += 1\n    return count\n",
  "score": 0.4,
  "valid": false
}

Payment details

Pay to0xaa7116cdda58286f4cda40c6f735762c22447104
AssetUSD Coin · 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913
NetworksBase
Schemesexact

Is this your API?

Pin it to the top of Developer Tools and the homepage with a featured placement.

Get featured →

More from Python Code Validator & similar services