Quickstart
Walk through the four API primitives —
/extract → /assess → /verify → /ask —
in five minutes. Pick Python or TypeScript below.
Prefer to run it in your browser? Skip the install and use the Colab notebook.
Get an API key
Sign up, then visit /api-integration and generate a key. You'll see it once — copy it somewhere safe.
Install the SDK
pip install lenz-io
npm install lenz-io
pipx install "lenz-io[cli]"
Prefer the terminal? The CLI ships inside the same package behind the cli extra. Run lenz login once to store your key (or set LENZ_API_KEY), then use the commands below.
Run the full ladder: extract → assess → verify
Paste any model output. Extract the claims, get a fast verdict from /assess, and escalate the low-confidence ones to the full /verify pipeline.
from lenz_io import Lenz client = Lenz(api_key="lenz_...") brief = """ Air pollution causes 7 million premature deaths annually. Bilingual children develop stronger executive function. """ # 1. Extract atomic claims (free, ~1s) claims = client.extract(text=brief).identified_claims for c in claims: print(" -", c) # 2. Fast verdict on all of them via /assess (~5-10s, 3-model panel) quick = client.assess(text=brief) for c in quick.claims: print(c.verdict, c.confidence, c.claim) # 3. Escalate low-confidence claims to /verify (~90s, 8-model pipeline) for c in quick.claims: if c.confidence == "low": deep = client.verify_and_wait(claim=c.claim) print(deep.verdict, deep.lenz_score, deep.confidence) for s in deep.sources[:3]: print(" -", s.title, s.url)
import { Lenz } from "lenz-io";
const client = new Lenz({ apiKey: "lenz_..." });
const brief = `
Air pollution causes 7 million premature deaths annually.
Bilingual children develop stronger executive function.
`;
// 1. Extract atomic claims (free, ~1s)
const { identified_claims } = await client.extract({ text: brief });
identified_claims.forEach(c => console.log(" -", c));
// 2. Fast verdict on all of them via /assess (~5-10s, 3-model panel)
const quick = await client.assess({ text: brief });
quick.claims.forEach(c => console.log(c.verdict, c.confidence, c.claim));
// 3. Escalate low-confidence claims to /verify (~90s, 8-model pipeline)
for (const c of quick.claims) {
if (c.confidence === "low") {
const deep = await client.verifyAndWait({ claim: c.claim });
console.log(deep.verdict, deep.lenz_score, deep.confidence);
}
}
# 1. Extract atomic claims (free, ~1s) lenz extract "Air pollution causes 7 million premature deaths annually." # 2. Fast verdict via /assess (~5-10s, 3-model panel) lenz assess "Air pollution causes 7 million premature deaths annually." # 3. Deep-verify with citations (~90s, 8-model pipeline) lenz verify "Air pollution causes 7 million premature deaths annually." # pipe any command through jq for machine-readable output lenz verify "<claim>" --json | jq '.verdict, .lenz_score'
Ask follow-ups on a verification
Once /verify lands, /ask grounds a chat thread on the verification's evidence. Same model, same citations, no re-research per turn.
reply = client.ask.send(
deep.verification_id,
message="Which source has the strongest evidence?",
)
print(reply.content)
const reply = await client.ask.send(deep.verification_id, {
message: "Which source has the strongest evidence?",
});
console.log(reply.content);
reply.content is
plain text with a small markdown subset:
**bold** / *italic*,
- or * bullet lists, and blank-line
paragraph breaks. The model only produces these — no headings,
no tables, no code blocks. Pass it through any markdown library
(markdown-it,
python-markdown)
or display it verbatim.
Next steps
Verify your own claims and the full pipeline runs. For production:
- Switch to webhook delivery instead of polling. Pass
webhook_urlonverify(); Lenz POSTs the typed payload to your endpoint when the pipeline lands. The SDK ships aLenzWebhookshandler that verifies signatures. - Use verify_batch for fan-out of multi-claim LLM output.
- Check the full API reference for every endpoint.
Common errors
Every error from the SDK carries cause, fix,
doc_url and a request_id you can quote on a
support ticket.
retry_after
carries seconds until the next allowed call.
credits_remaining tells you what's left
(0 here). Upgrade or wait for reset.
errors is a list of per-field complaints.
client.select(task_id, ...) to resume.
verify_and_wait exceeded the
timeout. The pipeline keeps running server-side; the exception's
task_id lets you resume via client.get_status().
Using the API in production? Read the API Terms of Service →