A lightweight resilience layer for OpenAI-compatible chat completion calls — retries, timeouts, circuit breaking, caching, structured output, and usage tracking, with one interface across providers.
import OpenAI from 'openai';
import { VernLLM } from 'vern-llm';
const llm = new VernLLM({
client: new OpenAI({ apiKey: process.env.OPENAI_API_KEY }),
model: 'gpt-4o',
maxRetries: 3,
timeoutMs: 10_000,
circuitBreaker: true,
});
const result = await llm.call({
systemPrompt: 'Return JSON: { "skills": string[] }',
userContent: 'Extract skills from: ...',
});Works with OpenAI, Groq, Mistral, DeepSeek, Cerebras, Together AI, Fireworks AI, Ollama, Anthropic, Gemini, AWS Bedrock, or any provider reachable over HTTP via a fromFetch adapter.
This is a pnpm monorepo with two workspaces:
| Path | Description |
|---|---|
packages/vern-llm |
The vern-llm npm package — source, tests, and its own README with the full API reference. |
apps/docs |
The Fumadocs-powered documentation site. |
Requires Node 22.13+ and pnpm (this repo pins pnpm@11.15.0).
pnpm installCommon scripts, runnable from the repo root:
| Command | Description |
|---|---|
pnpm build |
Build every workspace package (--if-present). |
pnpm build:package |
Build just vern-llm. |
pnpm build:docs |
Build just the docs site. |
pnpm dev |
Run dev mode across every workspace package. |
pnpm dev:package |
Watch-build vern-llm (tsdown --watch). |
pnpm dev:docs |
Run the docs site locally (next dev). |
pnpm typecheck |
Typecheck every workspace package. |
pnpm test |
Run the vern-llm test suite (vitest run). |
pnpm test:coverage |
Run tests with coverage (v8 provider). |
pnpm lint / lint:fix |
Lint the whole repo with oxlint. |
pnpm format / format:check |
Format the whole repo with oxfmt. |
pnpm changeset |
Record a changeset for the next vern-llm release. |
See packages/vern-llm/README.md for the complete API — installation, structured output, provider adapters, caching, circuit breaker, and more — and the docs site (or run pnpm dev:docs locally) for the full guided documentation.
- Fork and clone the repo, then
pnpm installat the root. - Make your change inside
packages/vern-llm(library code) orapps/docs(documentation). - Add tests for library changes — see the Development section of the package README for how the test suite is organized.
- Run
pnpm lint,pnpm typecheck, andpnpm testbefore opening a PR. - If your change affects the published package, add a changeset:
pnpm changeset.
MIT © LakBud
