Validate Python
validate_pythonCheck Python source without running it: parse, lint, type-check, and scan for security issues and credentials. Get diagnostics and a validity score to catch bugs before writing files.
Instructions
Check Python source without running it: parse, lint (ruff), type-check (mypy), AST security policy, credential scan. Safe on code you do not trust. Use it on every Python file you generated or edited, before writing it to disk. Alternatives: repair_python to get the corrected source instead of the diagnosis; execute_python to prove the code runs. Auth: a key is required. A free key covers this call, 100 per day, then HTTP 429; get one with POST /v1/keys. Credits are bought without an account, 1 per call: GET /v1/pricing says where to send the xDAI. Arguments: code: the whole file, 1..200000 bytes of UTF-8 measured after encoding (empty is refused with 400, larger with 413); a fragment is fine, but line and column numbers in the answer count from 1 in what you sent. language: must be 'python'; anything else is 400, and the field may be omitted. Of options only transpile_to (e.g. 'javascript', which returns a translated copy in transpiled) acts here; timeout_s, max_iterations, optimize, examples and expected_output need a pass that rewrites or runs the code, so send code alone. Ignored options are not refused, so a call that sets them looks like it worked; and code that does not parse is answered rather than refused: valid=false with the syntax error located, which is the point. Returns valid, score 0..1, diagnostics (rule, message, line, column), security findings, fixes, fixed_code and runtime; see outputSchema. The code and its verdict are retained to improve the service.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The source to check, as a whole file where possible: diagnostics carry the line and column of the text you send, and a fragment hides the imports and definitions the type check needs. A deployment may accept fewer bytes than the 200000 here. | |
| options | No | Tuning knobs. Most of them only take effect in the mode that does the corresponding work; see each field. | |
| language | No | The language of the code. A service that does not handle it refuses the request rather than guessing; the enum is shared across services, so it lists more than any one of them accepts. | python |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| meta | Yes | ||
| fixes | No | ||
| score | Yes | ||
| valid | Yes | ||
| runtime | No | ||
| security | No | ||
| fixed_code | No | ||
| transpiled | No | ||
| diagnostics | No |