Zero-dependency error recovery layer for LLM SDKs.
These are not your fault. They're transient SDK / network / proxy artifacts. But they kill your pipeline.
npm install @coder12-z/llm-shield
import { shield } from "@coder12-z/llm-shield";
import OpenAI from "openai";
const client = new OpenAI();
const safeCall = shield(async (prompt) =>
client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
response_format: { type: "json_object" },
}),
{ maxRetries: 3 }
);
const res = await safeCall("Return JSON with {name: string}");
could not parse JSON body) → retry with backoff + jitterEOF while parsing) → retry