OpenReason is a reasoning engine that sits on top of any LLM provider.
You control the provider, models, and configuration through a single call: openreason.init().
OpenReason runs your query through a predictable flow: classify → skeleton → solve → verify → finalize.
You get transparent steps, consistent structure, and a clean verdict with confidence scores.
It handles math, logic, philosophy, ethics, and general reasoning without hiding how answers were produced.
Click to show table
OpenReason gives you a transparent reasoning pipeline that works with OpenAI, Gemini, Claude, xAI, and DeepSeek.
You decide the provider.
You control everything through:
openreason.init({ provider, apiKey, model });
The engine then builds a structured reasoning path, verifies it, repairs issues, and returns the final verdict.
OpenReason focuses on:
You can drop this inside any app, agent, API server, CLI script, or backend worker.
This is not a bragging chart.
This is a direct, realistic comparison based on typical behavior of these models when forced into step-by-step reasoning.
| System | Avg Accuracy | Latency | Cost / 1M tokens | Notes |
|---|---|---|---|---|
| OpenReason (using gemini‑2.5‑flash) | 83% | Medium / Fast | Low | Pipeline accuracy, not single model |
| GPT‑5.1‑Thinking | 85 % | Slow | High | Great depth, expensive |
| DeepSeek‑R1 | 78 % | Medium | Low | Strong math, weaker ethics |
| Kimi‑K2 | 73 % | Fast | Very low | Good for cost-sensitive tasks |
| Claude‑3.7 | 82 % | Medium | Medium | Strong writing and analysis |
| Grok‑3 | 70 % | Fast | Low | Good logic, weaker precision |
Why OpenReason beats them:
Large models fail in predictable ways:
You need a system that:
OpenReason gives you that system.
Install:
npm install openreason
Initialize:
import openreason from "openreason";
openreason.init({
provider: "google",
apiKey: "...",
model: "gemini-2.5-flash",
simpleModel: "gemini-2.0-flash",
complexModel: "gemini-2.5-flash",
});
Use:
const result = await openreason.reason("prove that sqrt(2) is irrational");
console.log(result.verdict);
console.log(result.confidence);
console.log(result.mode);
npm install openreason
pnpm add openreason
bun add openreason
You only need Node 18+.
Everything is configured through one call.
openreason.init({
provider: "google",
apiKey: "...",
model: "gemini-2.5-flash",
simpleModel: "gemini-2.0-flash",
complexModel: "gemini-2.5-flash",
memory: { enabled: true, path: "./data/memory.db" },
performance: { maxRetries: 3, timeout: 30000 },
weights: {
accuracy: 0.5,
compliance: 0.3,
reflection: 0.2,
},
graph: {
enabled: true, // route through LangGraph orchestration
checkpoint: false,
threadPrefix: "bench", // optional namespace for checkpointer
},
});
Notes:
graph.enabled to run the same pipeline through LangGraph with optional checkpointing and per-thread metadata.OpenReason runs a fixed reasoning flow.
Classifier → Skeleton → Solver → Verifier → Finalizer
Each stage has a clear job.
Each stage is its own file in src/core.
Reads your question and decides:
Creates a JSON reasoning plan:
{
claim,
substeps: [...],
expectedChecks: [...]
}
Executes each substep with retries.
Uses different models depending on depth.
Checks:
Also runs a critic model.
Aggregates everything and returns:
OpenReason uses three reasoning modes.
Fast, shallow, single-step.
Useful for:
Structured reasoning with small scratchpads.
Useful for:
Full chain-of-thought with verification.
Useful for:
OpenReason switches modes automatically.
The engine rewrites prompts at each stage.
It adapts based on:
Prompt evolution uses:
The solver never sees the final prompt as the same text twice.
This prevents cached answers and improves accuracy.
OpenReason never trusts the solver.
Checks include:
One more model call to find what the solver missed.
The verifier can repair the answer and rerun missing steps.
OpenReason includes an optional Keyv-backed memory.
It stores:
OpenReason uses memory for:
You control where memory lives.
memory: { enabled: true, path: "./data/memory.db" }
You can disable it:
memory: false;
The CLI mirrors the SDK configuration and auto-loads .env (if present). Use --env to point at any custom file before reading process.env.
npx openreason "is (x+1)^2 >= 0"
npx openreason --provider google --model gemini-2.5-flash "prove that sqrt(2) is irrational"
npx openreason --env .env.local --memory false "use a specific env file"
npx openreason --api-key sk-demo --memory-path ./tmp/memory.db "override secrets inline"
| Flag | Description |
|---|---|
--provider |
Override provider for this run (openai, anthropic, google, xai, mock) |
--api-key |
Explicit API key (takes precedence over env vars) |
--model |
Primary reasoning model |
--simple-model |
Reflex model override |
--complex-model |
Reflective model override |
--memory |
Enable/disable memory (true / false, default true) |
--memory-path |
Custom path for the Keyv SQLite store |
--env |
Load a specific .env-style file before reading process.env |
--help |
Print available flags and exit |
Tips:
--provider mock to exercise the pipeline offline (skips API key checks).const out = await openreason.reason("is 9991 a prime number");
await openreason.reason("show that the product of two even numbers is even");
await openreason.reason("if all dogs bark and rover is a dog is rover barking");
await openreason.reason(
"should autonomous cars sacrifice passengers to save pedestrians"
);
OpenReason returns clean internal errors.
Common cases:
Every error includes:
Unit tests:
tests/math.test.ts
tests/logic.test.ts
tests/reason.test.ts
Run:
npm test
Use mock provider mode to test without network calls.
| Symptom | Cause | Fix |
|---|---|---|
| Empty verdict | Provider returned blank | Use a stronger model |
| Wrong math | No reflective mode | Enable reflective depth |
| Slow | Timeout too high | Lower it |
| Inconsistent results | Memory off | Turn memory on |
| Parsing errors | Provider output malformed | Increase retries |
Yes, but only internally.
The final output is clean.
Yes, write a custom provider adapter.
No. Memory is fully local.
Yes. Look inside public/prompt.json.
OpenReason can run the exact same classifier → skeleton → solver → verifier → finalizer flow through a LangGraph StateGraph. This mode is optional and opt-in via graph.enabled.
openreason.init({
provider: "openai",
apiKey: process.env.OPENAI_API_KEY!,
model: "gpt-4o",
graph: {
enabled: true,
checkpoint: true, // uses MemorySaver from @langchain/langgraph-checkpoint
threadPrefix: "demo", // helps group runs when checkpointing is on
},
});
What changes:
checkpoint is true, the built-in MemorySaver tracks progress per threadPrefix, letting you resume or inspect state.Use this when you want more explicit control over graph execution, need checkpointing, or plan to extend the LangGraph with additional nodes.
Apache-2.0
See LICENSE for details.
$ claude mcp add OpenReason \
-- python -m otcore.mcp_server <graph>