Quickstart

Walk through the four API primitives — /extract/assess/verify/ask — in five minutes. Pick Python or TypeScript below.

Open the quickstart in Google Colab Prefer to run it in your browser? Skip the install and use the Colab notebook.

1

Get an API key

Sign up, then visit /api-integration and generate a key. You'll see it once — copy it somewhere safe.

2

Install the SDK

Python
pip install lenz-io
TypeScript
npm install lenz-io
CLI
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.

3

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.

Python
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)
TypeScript
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);
  }
}
CLI
# 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'
4

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.

Python
reply = client.ask.send(
    deep.verification_id,
    message="Which source has the strongest evidence?",
)
print(reply.content)
TypeScript
const reply = await client.ask.send(deep.verification_id, {
  message: "Which source has the strongest evidence?",
});
console.log(reply.content);
Reply format. 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.
5

Next steps

Verify your own claims and the full pipeline runs. For production:

  • Switch to webhook delivery instead of polling. Pass webhook_url on verify(); Lenz POSTs the typed payload to your endpoint when the pipeline lands. The SDK ships a LenzWebhooks handler 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.

LenzAuthError — your API key is missing or invalid. Regenerate at /api-integration.
LenzRateLimitError — too many requests. retry_after carries seconds until the next allowed call.
LenzQuotaExceededError — your credit budget is spent for this period. credits_remaining tells you what's left (0 here). Upgrade or wait for reset.
LenzValidationError — request body is malformed. errors is a list of per-field complaints.
LenzNeedsInputError — the pipeline paused for clarification. Inspect the payload, then call client.select(task_id, ...) to resume.
LenzTimeoutErrorverify_and_wait exceeded the timeout. The pipeline keeps running server-side; the exception's task_id lets you resume via client.get_status().
Found this useful? The Python SDK lives at github.com/lenzhq/lenz-io-python and the Node SDK at github.com/lenzhq/lenz-io-node. File issues there — we read them.

Using the API in production? Read the API Terms of Service →