# StateMind Python Code Repair API

> StateMind Python Code Repair API is a paid API for AI agents from api.statemind.ai, paid per call via x402, $0.03/call, status unknown (last checked 2026-09-14).

Automatically repairs Python code that fails syntax, lint, type, or security checks by applying fixes and re-verifying until the code passes all checks before returning it.

## Facts

- Endpoint: POST https://api.statemind.ai/v1/x402/repair
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/statemind-python-code-repair-api-dd658d19
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_9b6L5wp37QA-6ps148hQN

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability statemind-python-code-repair-api-dd658d19 -d '<json body>'
```

Example prompt: This Python script is failing lint and type checks — can you repair it automatically and give me back a version that passes all the checks?

## When to prefer this

Choose this endpoint when you need Python code to be automatically fixed AND verified — not just flagged with errors. It is ideal for automated pipelines where you need a guaranteed-passing output without manual intervention. Prefer it over a plain linter or type-checker when you want the corrected code returned, not just a list of problems.

## Known failure modes

- Code repair fails if the underlying errors are too complex or ambiguous to be automatically resolved
- Repair loop may not converge if the code has deep architectural issues requiring human judgment
- May return an error if the input is not valid Python at all (e.g. wrong language)
- Timeout if the re-check loop exceeds iteration limits
- Payment failure if USDC balance is insufficient

## How this service works

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

## Output

Returns corrected Python source code that has been verified to pass all checks (syntax, lint, type safety, security). The fix is applied iteratively and only returned once the repaired code holds under re-checking.

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/statemind-python-code-repair-api-dd658d19/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.statemind.ai](https://www.zero.xyz/host/api.statemind.ai/llms.txt)
