Your First AI Endpoint
Build a JSON endpoint that calls a language model and returns a result.
An endpoint that calls an LLM
from larz import Larz
app = Larz(secret="...")
@app.post("/api/write")
def write(req):
prompt = req.json()["prompt"]
reply, usage = call_llm(prompt) # your provider call
return {"reply": reply}Return a dict and Larz serializes JSON automatically. usage here is the token count your provider reports (prompt + completion) โ you'll bill on it next.
Takeaways
- Any provider works โ you make the call, Larz handles the web layer.
- Capture the token usage the provider returns; it's what you meter.