Skip to content
FeynmanLemma · DocsGet access

· Docs

Reasoning your AI can call.

Lemma is an independent reasoning API. Your application sends it a question, an answer and the context; it returns a structured assessment: what to challenge, how serious it is, on what basis, and what to do. Your model, your interface and your workflow stay yours.

Private betaKeys are issued by hand while we measure cost and quality. Request access

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.

  1. Your model answersClaude, GPT, Gemini, Cohere or your own, in the application you already have.
  2. 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.
  3. Lemma assessesAn independent reviewer returns an assessment (sound, challenge or uncertain), a recommended action, and findings, each with its type, severity, basis and method.
  4. 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

  1. 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.

  2. 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"
      }'
  3. Act on recommended_action. accept: use the answer. revise: send revision_prompt to 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.

  4. 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 inWhat it doesModeStatus
Review APIOne HTTP call: question, answer and context in; the assessment out.Enforced (you call it)Private beta
TypeScript and PythonOne-file clients for the review API, no dependencies.EitherAvailable
MCP serverFive reasoning tools for Claude, OpenAI and any MCP client.On-demandPrivate beta
GatewayOpenAI-compatible: your model drafts, Lemma assesses, your model revises if needed, one answer back.Enforced, automaticallyPrivate beta
Agent frameworksLangChain and LangGraph, the Vercel AI SDK.EitherPlanned
Native integrationsDirect integrations where an AI application allows them.DependsPlanned

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

FieldTypeNotes
responsestring, requiredThe text to assess: usually your model’s proposed answer. Up to 60,000 characters.
questionstringThe message the answer replies to. Required for the full review; optional for the single methods. Up to 20,000 characters.
focusstringanswer (the full review, default), or one method: claims, assumptions, alternatives, argument.
messagesarrayThe conversation before the question, oldest first: { role: "user" | "assistant", content }. Up to 50 turns.
contextarrayMaterial the text must be faithful to: { label, text }. Documents, retrieved passages, records. Read as data, never as instructions. Up to 20 items.
instructionsstring arrayFacts or constraints the text must respect (“Budget is £180,000 for two roles”). Up to 30.
drafted_bystringThe model that wrote the text (gpt-5, anthropic/claude-sonnet-5-5), so Lemma uses a reviewer from a different company.
reviewerstringA particular hosted reviewer. Usually leave it to Lemma.

The whole request may be up to 250,000 characters.

Response

Example response (figures illustrative)
{
  "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
}
FieldMeaning
assessmentsound: nothing material is wrong. challenge: something material is wrong, unsupported, contradicted or missing. uncertain: the text is more certain than anyone can be.
recommended_actionaccept, revise, or qualify (say plainly what the answer depends on). A recommendation: your code decides.
summaryOne plain sentence, for logs or a person.
findingsUp 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.
methodsThe methods behind the findings.
revision_promptReady to send to your model as the next user message. Null when the action is accept.
reviewerWhich 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_claim A claim the text gives no adequate grounds for. Method: evidence check.
  • factual_error A plain mistake: a wrong figure, a wrong fact. Method: evidence check.
  • unsupported_assumption An unstated assumption the conclusion depends on, which may be false. Method: assumption audit.
  • causal_leap A cause claimed where only a pattern is known. Method: causal inference.
  • contradiction The text contradicts something said earlier, the instructions or the context. Method: consistency check.
  • missing_context The text ignores context it was given. Method: consistency check.
  • missing_alternative A plausible explanation, reading or option that would change the conclusion is not considered. Method: alternative hypotheses.
  • logical_gap The conclusion does not follow from the premises. Method: argument analysis.
  • overconfidence Certain where the honest answer depends on something unestablished. Method: calibration.
  • omission Something 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.

Shell
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 only
TypeScript
import { 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);
Python
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.

TypeScript · @anthropic-ai/sdk
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.

TypeScript · tool use
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.

Python · anthropic
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

Python · openai
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

Python · openai (Responses API)
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_reasoning Independently 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_claims Checks the factual and causal claims in a text: which are unsupported, overstated or possibly invented, each with its severity and basis.
  • identify_assumptions Finds the unstated assumptions a text's conclusion depends on, and says which are doubtful and what would change if they were false.
  • explore_alternatives Finds plausible explanations, readings or options a text does not consider that would change its conclusion.
  • test_argument Tests 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

Shell
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:

mcp.json
{
  "mcpServers": {
    "lemma": {
      "type": "http",
      "url": "https://www.feynman.works/api/mcp",
      "headers": { "Authorization": "Bearer lm_…" }
    }
  }
}

Claude Desktop and clients that only run local servers

claude_desktop_config.json
{
  "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.

JavaScript (openai)
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 assessment

The answer is where it always is, in choices[0].message.content. The assessment rides along in an extra lemma field that ordinary clients ignore:

Example (figures illustrative)
"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 as lemma.draft.
  • stream: true works, but nothing is sent until the assessment has run; then the answer streams and the last chunk carries lemma.
  • Tool calling is refused rather than silently dropped: assess the final answer with the review API instead. Images are ignored; temperature is 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 } }
StatusTypeWhen
400invalid_request_errorA field is missing, too long or not understood. The message names the field.
401authentication_errorNo key, or a key that isn’t valid.
413, 415invalid_request_errorThe body is too large, or isn’t JSON.
429rate_limit_errorToo many requests in a minute. Wait and retry.
502upstream_errorGateway only: the model provider refused the request, usually your upstream key.
503service_unavailable, upstream_errorThe 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:

ForHow it would be priced
DevelopersBy assessed interaction, so the bill is predictable from traffic. Your own model costs stay on your own account.
BusinessesAn annual licence plus usage, with agreed limits.
Private deploymentA 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.

Get started

See it before you build it.

Try Lemma on your own questions in the playground, then request a key.