@reasoningco/infer
v0.1.6
Published
TypeScript SDK for natural language to SQL — secure, auto-introspecting, production-ready
Readme
@reasoningco/infer
TypeScript SDK that turns natural language questions into safe, parameterized SQL — powered by LLMs, locked down by an 8-layer security pipeline.
Install
npm install @reasoningco/inferUsage
import { Infer, PostgresConnector } from '@reasoningco/infer';
const infer = new Infer({
connector: new PostgresConnector({
connectionString: process.env.DATABASE_URL,
}),
llm: { provider: 'openrouter', apiKey: process.env.LLM_API_KEY },
tenantId: 'tenant_123',
});
const result = await infer.ask('revenue by month last quarter');
console.log(result.rows);
await infer.close();Security
Every query passes through 8 layers before touching your database:
Input validation → LLM planner → Plan validator → Entity resolver → SQL compiler → SQL validator → Secure executor → Result sanitizer
LLM Providers
OpenRouter, OpenAI, Anthropic, and Ollama supported out of the box.
License
MIT — see LICENSE
