{"slug": "show-hn-vernllm-the-ai-resilience-layer-for-typescript", "title": "Show HN: VernLLM – The AI resilience layer for TypeScript", "summary": "VernLLM, a lightweight resilience layer for TypeScript LLM chat completions, has been released as an open-source npm package. It provides built-in retries with exponential backoff, per-attempt timeouts, circuit breaking, caching, and structured output validation via Zod, supporting over 30 LLM providers including OpenAI, Anthropic, and Gemini. The library aims to eliminate the need for developers to write repetitive defensive code for LLM API calls.", "body_md": "# Reliable LLM calls,\n\nby default.\n\nA lightweight resilience layer for LLM chat completions. Retries, timeouts, caching, and circuit breaking, dependency-light and typed from the start.\n\n`$ npm install vern-llm`\n\n## What this call actually does.\n\n`maxRetries: 3`\n\n→ 3 attempts with exponential backoff`timeoutMs: 10_000`\n\n→ 10s hard timeout per attempt`circuitBreaker: true`\n\n→ Trips after repeated failures`onUsage`\n\n→ Token usage reported per call`cachedLLMCall`\n\n→ Identical calls skip the network`schema`\n\n→ Response validated and typed via Zod\n\n`maxRetries: 3`\n\n### Retry with backoff\n\nRetries a failed call up to N times with exponential backoff and jitter between attempts.\n\n`timeoutMs: 10_000`\n\n### Per-attempt timeout\n\nEach attempt is raced against a hard timeout, so no single request can hang the call.\n\n`circuitBreaker: true`\n\n### Circuit breaker\n\nTrips after repeated failures and rejects immediately while open. Call getCircuitState() to inspect it.\n\n`nonRetryableStatus: [400, 401, 403, 404]`\n\n### Fail-fast status codes\n\nStatus codes you mark as non-retryable skip the retry loop entirely.\n\n`llm.cachedLLMCall({ cacheKey, ttl, call })`\n\n### Caching\n\nWraps call() with a pluggable cache adapter. Identical calls return without hitting the network.\n\n`schema: HiringSummarySchema`\n\n### Structured output\n\nPass a Zod schema inside call params and receive validated, typed JSON.\n\n`onUsage: ({ totalTokens }) => {}`\n\n### Usage tracking\n\nReports prompt, completion, and total tokens whenever the provider returns usage data.\n\n`logger: myLogger`\n\n### Pluggable logger\n\nBring your own Logger implementation or fall back to the built-in console logger.\n\n[OpenAI](/docs/adapters)\n\n[Anthropic](/docs/adapters/anthropic)\n\n[Gemini](/docs/adapters/gemini)\n\n[Groq](/docs/adapters/openai-compatible)\n\n[Mistral](/docs/adapters/openai-compatible)\n\n[DeepSeek](/docs/adapters/openai-compatible)\n\n[Cerebras](/docs/adapters/openai-compatible)\n\n[Together AI](/docs/adapters/openai-compatible)\n\n[Fireworks AI](/docs/adapters/openai-compatible)\n\n[Ollama](/docs/adapters/openai-compatible)\n\n[OpenRouter](/docs/adapters/openai-compatible)\n\n[Perplexity](/docs/adapters/openai-compatible)\n\n[DeepInfra](/docs/adapters/openai-compatible)\n\n[Novita](/docs/adapters/openai-compatible)\n\n[Hyperbolic](/docs/adapters/openai-compatible)\n\n[Moonshot (Kimi)](/docs/adapters/openai-compatible)\n\n[Zhipu (GLM)](/docs/adapters/openai-compatible)\n\n[LM Studio](/docs/adapters/openai-compatible)\n\n[vLLM](/docs/adapters/openai-compatible)\n\n[xAI (Grok)](/docs/adapters/openai-compatible)\n\n[NVIDIA NIM](/docs/adapters/openai-compatible)\n\n[Vercel AI Gateway](/docs/adapters/openai-compatible)\n\n[Cloudflare Workers AI](/docs/adapters/openai-compatible)\n\n[GitHub Models](/docs/adapters/openai-compatible)\n\n[Nebius AI Studio](/docs/adapters/openai-compatible)\n\n[SambaNova Cloud](/docs/adapters/openai-compatible)\n\n[Baseten](/docs/adapters/openai-compatible)\n\n[Featherless AI](/docs/adapters/openai-compatible)\n\n[Friendli AI](/docs/adapters/openai-compatible)\n\n[SiliconFlow](/docs/adapters/openai-compatible)\n\n[Parasail](/docs/adapters/openai-compatible)\n\n[StepFun](/docs/adapters/openai-compatible)\n\n[MiniMax](/docs/adapters/openai-compatible)\n\n[Lambda Labs](/docs/adapters/openai-compatible)\n\n[Snowflake Cortex](/docs/adapters/openai-compatible)\n\n[Anyscale](/docs/adapters/openai-compatible)\n\n[Lepton AI](/docs/adapters/openai-compatible)\n\n[kluster.ai](/docs/adapters/openai-compatible)\n\n[Inference.net](/docs/adapters/openai-compatible)\n\n[Infermatic](/docs/adapters/openai-compatible)\n\n[AtlasCloud](/docs/adapters/openai-compatible)\n\n[01.AI (Yi)](/docs/adapters/openai-compatible)\n\n[AWS Bedrock](/docs/adapters/bedrock)\n\n[Custom HTTPS API](/docs/adapters/custom-fetch)\n\nEvery project calling an LLM API ends up writing the same defensive code: retry logic, timeouts, a circuit breaker, a cache layer, usually copied between projects and slightly wrong each time. VernLLM gives you those primitives with sensible defaults out of the box, so you keep your existing client and just wrap it.\n\nNo. VernLLM wraps the client you already have, OpenAI, Anthropic, Gemini, Bedrock, or anything OpenAI-compatible, so you keep your existing setup and just route calls through it.\n\nYes. cachedLLMCall works with any adapter implementing get/set/delete, so you can plug in Redis, a database, or your own store instead of the built-in in-memory cache.\n\nYes, written in TypeScript from the ground up. Structured output schemas, call params, and errors are all typed, so mistakes surface at compile time instead of at runtime.\n\nZero bundled dependencies. Zod and provider SDKs are peer dependencies, and VernLLM only relies on their shapes structurally, so it stays dependency-light and typed from the start.\n\n12.1 kB minified, 4.4 kB minified and gzipped. Small enough to drop into a project without thinking twice about it.\n\nYes, VernLLM is MIT licensed and open source. Use it in personal or commercial projects, fork it, or contribute back on GitHub.", "url": "https://wpnews.pro/news/show-hn-vernllm-the-ai-resilience-layer-for-typescript", "canonical_source": "https://vernllm.vercel.app", "published_at": "2026-07-29 17:05:25+00:00", "updated_at": "2026-07-29 17:22:27.400774+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-tools", "ai-infrastructure"], "entities": ["VernLLM", "OpenAI", "Anthropic", "Gemini", "Zod"], "alternates": {"html": "https://wpnews.pro/news/show-hn-vernllm-the-ai-resilience-layer-for-typescript", "markdown": "https://wpnews.pro/news/show-hn-vernllm-the-ai-resilience-layer-for-typescript.md", "text": "https://wpnews.pro/news/show-hn-vernllm-the-ai-resilience-layer-for-typescript.txt", "jsonld": "https://wpnews.pro/news/show-hn-vernllm-the-ai-resilience-layer-for-typescript.jsonld"}}