Larz 1.3: Modern API — typed validation, dependency injection & SSE
FastAPI-style ergonomics — typed binding, dependency injection, SSE — with zero dependencies and nothing phoning home.
1.2 made Larz revenue-native. 1.3 is the parity release: the modern-API ergonomics developers expect from FastAPI, delivered with zero dependencies.
pip install --upgrade larz # 1.3.0
Typed request validation, from the signature
Annotate a handler's parameters and Larz validates, coerces and injects them. Bad input is a
clean 422 with per-field errors — no schema boilerplate.
@app.post("/items")
def create(req, name: str, qty: int = 1, active: bool = True):
return {"name": name, "qty": qty} # types coerced; missing 'name' -> 422
Dataclass bodies
from dataclasses import dataclass
@dataclass
class Order:
product: str
price: float
qty: int = 1
@app.post("/order")
def order(req, o: Order): # the JSON body -> a validated Order
return {"total": o.price * o.qty}
Dependency injection
def current_user(req):
return db.get(req.session.get("user"))
@app.get("/me")
def me(req, user=Depends(current_user)): # resolved & cached per request
return user.email
Server-Sent Events & streaming
Real-time push and large downloads over plain WSGI — no websockets required:
@app.get("/events")
def events(req):
def stream():
for i in range(10):
yield ("tick", str(i)); time.sleep(1)
return Response.sse(stream())
CORS, lifecycle, and a typed API explorer
app.enable_cors() handles preflight; @app.on_startup /
@app.on_shutdown run setup and teardown (also under gunicorn); and
/openapi.json now reflects your typed signatures, rendered by the built-in,
self-contained /docs explorer.
And it runs on your infrastructure
Worth repeating: Larz has zero runtime dependencies and makes no calls to any Larz or vendor server. Everything runs on your machine — we proved it by running a full app (payments, auth, AI metering, uploads, analytics) entirely offline with the network hard-blocked. No telemetry, no phone-home. Your data and your customers stay in your database.
See the changelog and the typed-API example.
FAQ
Is the typed validation like FastAPI/Pydantic?
Similar ergonomics — you annotate parameters and get validation, coercion and OpenAPI — but with zero dependencies. Larz uses the standard library's typing and dataclasses, no Pydantic.
Does Larz support WebSockets now?
1.3 ships Server-Sent Events (real-time push over plain WSGI). Full bidirectional WebSockets arrive with the async ASGI core in v2.0.
Does Larz phone home or send telemetry?
No. Larz makes no calls to any Larz or vendor server; the only network calls are to services you configure with your own keys. It runs entirely on your infrastructure.
release1.3