# lpy agent endpoint Base URL: the host you fetched this from (https://lpylang.dev in production) Install the CLI from this host, then check and build locally. This page is generated in lpy. ## What lpy is Python-shaped source. rustc borrow-checks. LLVM emits native code. crates.io for libraries. Do not invent a second package index. Do not emit TypeScript. ## Human UI GET / playground + token studio GET /api/stats {"ok":true,"engine":"lpy","save_vs_rust":31,"save_vs_python":11} ## Agent API (CORS *) POST /api/check body = lpy source (text/plain) OR JSON {"source":"..."} -> {"ok":bool,"output":"..."} rustc diagnostics remapped to .lpy POST /api/expand body as above -> {"ok":bool,"rust":"..."} POST /api/run body as above -> {"ok":bool,"output":"..."} requires def main(), 12s timeout POST /api/tokens body = text or JSON {"source":"..."} -> {"ok":true,"o200k":N,"cl100k":N,"chars":N} GET /api/data bench pairs with python/lpy/rust sources and token counts GET /llms.txt this file GET /openapi.json machine spec GET /tack.md separate product: reasoning-token spec (not required for lpy; prompt/reply stay English) ## Rules for generated lpy - Valid Python 3 syntax. Implicit last-expression return. Methods may omit self. - Types: int float bool str list[T] dict[K,V] T|None - Ok or Err: type Result[T,E] = Ok(T) | Err(E) - Imports: from crate import name (list crate in lpy.toml) - from fs import read_to_string; from env import var - Trailing ? is Rust ? - No slices, no **kwargs, no nested def, no try/except, no import crate as module ## Local toolchain Python 3.11+, rustc, cargo if you use crates. From this host (no clone): curl -sSf $HOST/install.sh | sh -s -- --new ./myapp lpy doctor lpy check ./myapp/main.lpy lpy build ./myapp/main.lpy -o ./myapp/app --opt size GET /install.sh bootstrap script (origin baked in) GET /lpy.tgz source tree the script pip-installs `lpy new` writes AGENTS.md and lpy.json (commands + forbidden syntax). ## Example curl -sS -X POST $HOST/api/check --data-binary $'def add(a: int, b: int) -> int:\n a + b\n'