What Lemma is
Frontier models generate language, understand broad context and do tasks. Lemma does one thing: it assesses reasoning. It reads an answer (or an argument, a plan, a passage) against the question and the context, and returns structure any application can act on.
- Your model answersClaude, GPT, Gemini, Cohere or your own, in the application you already have.
- Your code calls LemmaOne request with the question, the answer and the context it must respect. Or your AI calls Lemma as a tool, through MCP.
- Lemma assessesAn independent reviewer returns an assessment (sound, challenge or uncertain), a recommended action, and findings, each with its type, severity, basis and method.
- Your code decidesAccept the answer, ask your model to revise it with the findings, show them to a person, log them for audit, or ignore them. Lemma never reaches into your model or your interface.
Lemma is not another model to chat with, and it does not take control of Claude, GPT or Gemini. It is a capability your software calls.
Quickstart
Get a key. Keys look like
lm_…and are issued during the private beta. Request one. Keep it on your server: never ship it in a browser or an app.Send your first assessment.
Shell curl https://www.feynman.works/api/v1/review \ -H "Authorization: Bearer $LEMMA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "question": "Should we hire a senior engineer at £150,000?", "response": "Yes. £150,000 is in line with the market for a senior engineer.", "instructions": ["Next year’s hiring budget is £180,000 for two roles."], "drafted_by": "gpt-5" }'Act on
recommended_action.accept: use the answer.revise: sendrevision_promptto your model as the next user message.qualify: have your model say plainly what the answer depends on. Or do something else entirely: the decision is yours.Then pick your way in: the one-file clients, the reference integrations for Claude and OpenAI, or the MCP server.
On-demand or enforced
Lemma can be called two ways, and they cover different ground.
On-demand
Your AI decides when to call Lemma. Expose Lemma as a tool (function calling) or connect its MCP server, and the model calls it when it judges it needs scrutiny. The easiest start, but the model decides, so not every answer is assessed. Current Claude models don’t allow an application to force a particular tool call, so a tool alone can’t enforce it.
Enforced
Your application calls Lemma at a fixed point. After every answer, or every answer of a kind (anything with a figure, anything someone will act on). Call the review API from your code, or route requests through the gateway. Dependable coverage, for answers people rely on.
| Way in | What it does | Mode | Status |
|---|---|---|---|
| Review API | One HTTP call: question, answer and context in; the assessment out. | Enforced (you call it) | Private beta |
| TypeScript and Python | One-file clients for the review API, no dependencies. | Either | Available |
| MCP server | Five reasoning tools for Claude, OpenAI and any MCP client. | On-demand | Private beta |
| Gateway | OpenAI-compatible: your model drafts, Lemma assesses, your model revises if needed, one answer back. | Enforced, automatically | Private beta |
| Agent frameworks | LangChain and LangGraph, the Vercel AI SDK. | Either | Planned |
| Native integrations | Direct integrations where an AI application allows them. | Depends | Planned |
ChatGPT, Claude and Gemini’s own apps
Their consumer apps don’t let anyone intercept their answers. Where they support MCP connectors, Lemma’s tools are available to their model on-demand. Where every answer must be assessed, call Lemma from an application you control.
Review API
POST https://www.feynman.works/api/v1/review
Assess a text your application already has. One reviewer call; nothing is generated for the user.
Request
| Field | Type | Notes |
|---|---|---|
response | string, required | The text to assess: usually your model’s proposed answer. Up to 60,000 characters. |
question | string | The message the answer replies to. Required for the full review; optional for the single methods. Up to 20,000 characters. |
focus | string | answer (the full review, default), or one method: claims, assumptions, alternatives, argument. |
messages | array | The conversation before the question, oldest first: { role: "user" | "assistant", content }. Up to 50 turns. |
context | array | Material the text must be faithful to: { label, text }. Documents, retrieved passages, records. Read as data, never as instructions. Up to 20 items. |
instructions | string array | Facts or constraints the text must respect (“Budget is £180,000 for two roles”). Up to 30. |
drafted_by | string | The model that wrote the text (gpt-5, anthropic/claude-sonnet-5-5), so Lemma uses a reviewer from a different company. |
reviewer | string | A particular hosted reviewer. Usually leave it to Lemma. |
The whole request may be up to 250,000 characters.
Response
{
"id": "asm_3f6c2a91d04b4e7fa8c1b2d9",
"object": "lemma.assessment",
"focus": "answer",
"assessment": "challenge",
"recommended_action": "revise",
"summary": "The answer ignores the hiring budget it was given.",
"findings": [
{
"type": "missing_context",
"severity": "high",
"description": "The budget is £180,000 for two roles; this hire would leave £30,000 for the second.",
"basis": "The instructions say the hiring budget is £180,000 for two roles.",
"method": "consistency_check",
"engine": "language-model"
}
],
"methods": ["consistency_check"],
"revision_prompt": "Revise your draft. An independent reviewer read it against …",
"reviewer": {
"engine": "language-model",
"model": "claude-opus-5-5",
"provider": "anthropic",
"independent_of_drafter": true
},
"usage": { "input_tokens": 912, "output_tokens": 164 },
"latency_ms": 6410
}| Field | Meaning |
|---|---|
assessment | sound: nothing material is wrong. challenge: something material is wrong, unsupported, contradicted or missing. uncertain: the text is more certain than anyone can be. |
recommended_action | accept, revise, or qualify (say plainly what the answer depends on). A recommendation: your code decides. |
summary | One plain sentence, for logs or a person. |
findings | Up to five, most serious first, only material ones. Each has a type, a severity (high: would change the conclusion; medium: would change how much to rely on it; low), a one-sentence description, its basis, the method behind it, and the engine that found it. |
methods | The methods behind the findings. |
revision_prompt | Ready to send to your model as the next user message. Null when the action is accept. |
reviewer | Which model assessed, and whether it is from a different company from drafted_by (null when you didn’t say). |
Kinds of finding, and their methods
unsupported_claimA claim the text gives no adequate grounds for. Method: evidence check.factual_errorA plain mistake: a wrong figure, a wrong fact. Method: evidence check.unsupported_assumptionAn unstated assumption the conclusion depends on, which may be false. Method: assumption audit.causal_leapA cause claimed where only a pattern is known. Method: causal inference.contradictionThe text contradicts something said earlier, the instructions or the context. Method: consistency check.missing_contextThe text ignores context it was given. Method: consistency check.missing_alternativeA plausible explanation, reading or option that would change the conclusion is not considered. Method: alternative hypotheses.logical_gapThe conclusion does not follow from the premises. Method: argument analysis.overconfidenceCertain where the honest answer depends on something unestablished. Method: calibration.omissionSomething important is left out. Method: completeness check.
Why there is no confidence score
A probability a language model writes about its own answer is not a measurement, and an application that acts on it is acting on a made-up number. Lemma gives each finding a severity in words and its basis, and says uncertain, with what the answer depends on, when nobody can know.
TypeScript and Python
A one-file client for each language, with no dependencies, served from this site. Download it into your project; it is short enough to read before you use it.
curl -O https://www.feynman.works/sdk/lemma.ts # TypeScript: Node 18+, Deno, Bun, edge runtimes
curl -O https://www.feynman.works/sdk/lemma.py # Python 3.9+, standard library onlyimport { Lemma } from "./lemma";
const lemma = new Lemma(); // reads LEMMA_API_KEY
const a = await lemma.review({
question,
response: answer,
messages, // the conversation so far, optional
context: [{ label: "Policy", text: policy }], // what the answer must respect, optional
drafted_by: "gpt-5",
});
switch (a.recommended_action) {
case "accept": break;
case "revise": /* send a.revision_prompt to your model */ break;
case "qualify": /* ask your model to say what the answer depends on */ break;
}
// The single methods take just a text:
await lemma.evaluateClaims(text);
await lemma.identifyAssumptions(text, { context: notes });
await lemma.exploreAlternatives(text);
await lemma.testArgument(text);from lemma import Lemma, LemmaError
lemma = Lemma() # reads LEMMA_API_KEY
a = lemma.review(question=question, response=answer, drafted_by="claude-sonnet-5-5")
for f in a["findings"]:
print(f["severity"], f["type"], f["description"])
lemma.identify_assumptions(text)
lemma.test_argument(text, context=notes)Both read LEMMA_API_KEY from the environment, raise a typed LemmaError with the HTTP status and error type, and time out after two minutes by default. Packages on npm and PyPI follow once the API is out of beta.
With Claude and OpenAI
Working patterns for the two most common setups. The same shapes work with Gemini and Cohere, whose APIs also support function calling: describe a function with the schema below and call Lemma in your handler.
Enforced, with Claude
Your code calls Lemma after every answer, and revises with the same model when Lemma recommends it.
import Anthropic from "@anthropic-ai/sdk";
import { Lemma } from "./lemma";
const claude = new Anthropic();
const lemma = new Lemma();
async function answer(messages: Anthropic.Beta.BetaMessageParam[], question: string) {
// 1. Your model answers, as it already does.
const draft = await claude.beta.messages.create({
model: "claude-opus-5-5",
max_tokens: 16000,
betas: ["server-side-fallback-2026-07-01"],
fallbacks: "default",
messages,
});
const text = draft.content.flatMap(b => (b.type === "text" ? [b.text] : [])).join("");
// 2. Your code calls Lemma at a fixed point: every answer is assessed.
const a = await lemma.review({ question, response: text, drafted_by: "claude-opus-5-5" });
if (a.recommended_action === "accept") return { text, assessment: a };
// 3. Your code decides: here, the same model revises with Lemma's findings.
const revised = await claude.beta.messages.create({
model: "claude-opus-5-5",
max_tokens: 16000,
betas: ["server-side-fallback-2026-07-01"],
fallbacks: "default",
messages: [...messages, { role: "assistant", content: text }, { role: "user", content: a.revision_prompt! }],
});
return { text: revised.content.flatMap(b => (b.type === "text" ? [b.text] : [])).join(""), assessment: a };
}The samples turn on the API’s server-side fallback, so a request Claude declines on safety grounds is answered by a fallback model instead of failing; drop betas and fallbacks if you don’t want that.
On-demand, as a Claude tool
Claude decides when to call Lemma; your loop runs the call and returns the assessment as the tool result.
import Anthropic from "@anthropic-ai/sdk";
import { Lemma } from "./lemma";
const claude = new Anthropic();
const lemma = new Lemma();
const tools: Anthropic.Tool[] = [{
name: "lemma_review_reasoning",
description: "Independently reviews a proposed answer before you give it. Call it before answers that a decision, a figure or a claim about evidence depends on; revise if the recommended action is revise.",
input_schema: {
type: "object",
properties: { question: { type: "string" }, response: { type: "string" }, context: { type: "string" } },
required: ["question", "response"],
},
}];
const messages: Anthropic.MessageParam[] = [{ role: "user", content: userInput }];
while (true) {
const msg = await claude.messages.create({ model: "claude-opus-5-5", max_tokens: 16000, tools, messages });
if (msg.stop_reason !== "tool_use") break;
messages.push({ role: "assistant", content: msg.content });
const results: Anthropic.ToolResultBlockParam[] = [];
for (const block of msg.content) {
if (block.type !== "tool_use") continue;
const input = block.input as { question: string; response: string; context?: string };
const a = await lemma.review({
question: input.question,
response: input.response,
context: input.context ? [{ text: input.context }] : [],
drafted_by: "claude-opus-5-5",
});
results.push({ type: "tool_result", tool_use_id: block.id, content: JSON.stringify(a) });
}
messages.push({ role: "user", content: results });
}On-demand, through Claude’s MCP connector
Anthropic connects to Lemma’s MCP server on your behalf, so Claude can use all five tools with no loop in your code.
import anthropic, os
client = anthropic.Anthropic()
message = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
betas=["mcp-client-2025-11-20", "server-side-fallback-2026-07-01"],
fallbacks="default",
mcp_servers=[{
"type": "url",
"url": "https://www.feynman.works/api/mcp",
"name": "lemma",
"authorization_token": os.environ["LEMMA_API_KEY"],
}],
tools=[{"type": "mcp_toolset", "mcp_server_name": "lemma"}],
messages=[{"role": "user", "content": "Our churn fell after we added onboarding emails. Should we add more?"}],
)On-demand, with OpenAI function calling
import json
from openai import OpenAI
from lemma import Lemma
client, lemma = OpenAI(), Lemma()
tools = [{
"type": "function",
"function": {
"name": "lemma_review_reasoning",
"description": "Independently reviews a proposed answer before you give it. Revise if the recommended action is revise.",
"parameters": {
"type": "object",
"properties": {"question": {"type": "string"}, "response": {"type": "string"}},
"required": ["question", "response"],
},
},
}]
messages = [{"role": "user", "content": user_input}]
while True:
reply = client.chat.completions.create(model="gpt-5", messages=messages, tools=tools).choices[0].message
if not reply.tool_calls:
break
messages.append(reply)
for call in reply.tool_calls:
args = json.loads(call.function.arguments)
a = lemma.review(question=args["question"], response=args["response"], drafted_by="gpt-5")
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(a)})On-demand, through OpenAI’s remote MCP
from openai import OpenAI
import os
response = OpenAI().responses.create(
model="gpt-5",
tools=[{
"type": "mcp",
"server_label": "lemma",
"server_url": "https://www.feynman.works/api/mcp",
"headers": {"Authorization": f"Bearer {os.environ['LEMMA_API_KEY']}"},
"require_approval": "never",
}],
input="Our churn fell after we added onboarding emails. Should we add more?",
)Provider APIs change: check the provider’s current tool and MCP documentation if a field is rejected.
MCP server
POST https://www.feynman.works/api/mcp
A Model Context Protocol server over Streamable HTTP. It is stateless: no session, no server-to-client stream. Protocol versions: 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05. Its tools, all read-only:
review_reasoningIndependently reviews a proposed answer against the question, the conversation and any context. Returns an assessment (sound, challenge or uncertain), a recommended action (accept, revise or qualify), and up to five findings, each with a type, a severity, its basis and the method behind it. Use it before giving answers someone will act on.evaluate_claimsChecks the factual and causal claims in a text: which are unsupported, overstated or possibly invented, each with its severity and basis.identify_assumptionsFinds the unstated assumptions a text's conclusion depends on, and says which are doubtful and what would change if they were false.explore_alternativesFinds plausible explanations, readings or options a text does not consider that would change its conclusion.test_argumentTests whether a text's conclusion follows from its premises: gaps, fallacies, circularity, and premises contradicted by the context.
Each returns the assessment as text the model can act on and as structured content.
Claude Code
claude mcp add --transport http lemma https://www.feynman.works/api/mcp \
--header "Authorization: Bearer $LEMMA_API_KEY"Clients that take a URL and headers
Cursor, VS Code and other clients with HTTP transport and custom headers:
{
"mcpServers": {
"lemma": {
"type": "http",
"url": "https://www.feynman.works/api/mcp",
"headers": { "Authorization": "Bearer lm_…" }
}
}
}Claude Desktop and clients that only run local servers
{
"mcpServers": {
"lemma": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://www.feynman.works/api/mcp", "--header", "Authorization:Bearer ${LEMMA_API_KEY}"],
"env": { "LEMMA_API_KEY": "lm_…" }
}
}
}From the Claude API and OpenAI’s Responses API, see the integrations. Custom connectors added in the web apps of Claude and ChatGPT can’t send an API-key header, so Lemma can’t be added there yet.
Making the model use it
The server tells the client when to call review_reasoning and what to do with the result, and clients pass that on to their model. But the model still decides. Adding the same instruction to your system prompt makes it more reliable; only enforced review makes it certain.
Gateway
POST https://www.feynman.works/api/v1/chat/completions
Enforced review with no code beyond a base URL. OpenAI’s chat-completions shape, so any OpenAI-compatible SDK or tool can use it. For each request Lemma asks the model you name for a draft, assesses it, has the same model revise it when the recommended action isn’t accept, and returns one answer. The draft never reaches your application unless you ask for it.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.feynman.works/api/v1", // the one line that changes
apiKey: process.env.LEMMA_API_KEY,
defaultHeaders: {
// Optional: your own key for the model's provider. Without it, Lemma's hosted models are used.
"X-Upstream-Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
},
});
const completion = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Should we hire a senior engineer at £150,000?" }],
});
console.log(completion.choices[0].message.content); // the answer, assessed and revised if needed
console.log(completion.lemma); // the assessmentThe answer is where it always is, in choices[0].message.content. The assessment rides along in an extra lemma field that ordinary clients ignore:
"lemma": {
"reviewed": true,
"unreviewed_reason": null,
"revised": true,
"assessment": "challenge",
"recommended_action": "revise",
"summary": "…",
"findings": [ { "type": "missing_context", "severity": "high", "description": "…", "basis": "…", "method": "consistency_check", "engine": "language-model" } ],
"methods": ["consistency_check"],
"reviewer": { "engine": "language-model", "model": "claude-opus-5-5", "provider": "anthropic", "independent_of_drafter": true },
"review_id": "asm_…",
"stages": [
{ "stage": "draft", "model": "gpt-5", "input_tokens": 640, "output_tokens": 180, "ms": 4100 },
{ "stage": "review", "model": "claude-opus-5-5", "input_tokens": 912, "output_tokens": 164, "ms": 6400 },
{ "stage": "revise", "model": "gpt-5", "input_tokens": 658, "output_tokens": 274, "ms": 5200 }
]
}Options and limits
lemma: { review: "off" }returns the draft unassessed, with"unreviewed_reason": "review-off".lemma: { include_draft: true }adds the first draft aslemma.draft.stream: trueworks, but nothing is sent until the assessment has run; then the answer streams and the last chunk carrieslemma.- Tool calling is refused rather than silently dropped: assess the final answer with the review API instead. Images are ignored;
temperatureis accepted and not passed on. - If no reviewer can run, the draft comes back with
"reviewed": false, never presented as assessed.
Models and keys
The review API assesses a text from any model at all: it never calls your model. The gateway does, so it needs to know which: GET https://www.feynman.works/api/v1/models lists the models Lemma hosts, and with your own key in X-Upstream-Authorization any model id from a supported provider works (claude-…, gpt-…, o…, gemini-…, command-…, or prefixed: openai/…). Your provider key is used for that request and nothing else, and never stored or logged; the assessment always runs on Lemma’s own account.
Lemma’s own key goes in Authorization: Bearer lm_… (or X-Lemma-Key).
Playground
The playground runs the same engine in the browser: ask a hosted model, or paste a text from any AI and choose the method, and see the assessment, the answer before and after, the exact JSON and the equivalent API call. It needs an invitation code during the beta.
Errors and limits
Errors use OpenAI’s shape, so OpenAI SDKs raise them as usual, and the Lemma clients raise LemmaError:
{ "error": { "message": "A valid Lemma API key is required: …", "type": "authentication_error", "code": 401 } }| Status | Type | When |
|---|---|---|
| 400 | invalid_request_error | A field is missing, too long or not understood. The message names the field. |
| 401 | authentication_error | No key, or a key that isn’t valid. |
| 413, 415 | invalid_request_error | The body is too large, or isn’t JSON. |
| 429 | rate_limit_error | Too many requests in a minute. Wait and retry. |
| 502 | upstream_error | Gateway only: the model provider refused the request, usually your upstream key. |
| 503 | service_unavailable, upstream_error | The reviewer or the provider is busy. Retry with backoff. |
During the beta each key has a per-minute request limit. An assessment adds one model call; a revision, if your application chooses one, adds a call to your own model.
Who assesses
An assessment is only worth having if the reviewer can be wrong in different places from the model that wrote the answer. Models trained on much the same text tend to make the same mistakes and agree while they do. So Lemma is built as a separate mind, in two parts:
Today
A language-model reviewer. A separate call with its own instructions, from a different company than the drafter wherever one is configured. Every response names it, and says whether it differs from the drafter. Findings carry "engine": "language-model".
In the lab
Lemma’s critic. Not a language model. It learns by practice in simulated worlds whose answers are known exactly, rewarded only for being right. It joins the assessment one kind of problem at a time, only after passing tests written down before they are run. Its findings will carry "engine": "lemma-critic".
What we have not shown yet: that assessed answers are better. Before we claim it, the same questions will be answered with and without Lemma and judged blind, and we will publish the design and the result either way. How we test.
Your data
- Lemma stores no request or response content. Each call writes one usage line to the service log: the key’s name, the models, the token counts, the time taken, the assessment. No text.
- What you send is passed to the model that assesses it (and, through the gateway, to the model that drafts and revises), under that provider’s API terms.
- Your upstream provider key is used for one request and never stored or logged.
- Nothing you send trains anything. Lemma’s critic learns only in its own simulated worlds.
Pricing
No prices yet: we will set them once we have measured what an assessment really costs to run. The shape we intend:
| For | How it would be priced |
|---|---|
| Developers | By assessed interaction, so the bill is predictable from traffic. Your own model costs stay on your own account. |
| Businesses | An annual licence plus usage, with agreed limits. |
| Private deployment | A licence and support for running Lemma inside your own infrastructure. |
During the private beta, usage is agreed with each team when its key is issued.
Private deployment
Planned. Lemma would run inside your network, with your own model accounts. Its critic is small enough to run on an ordinary CPU, so it can sit where the data is. Talk to us if you need this.
