Non-Blocking Client Wrapper (shdw.wrapClient) & Fail-Silent Guarantee
Getting Started & SDK
#wrapClient#sdk#openai#anthropic#gemini#sse#streaming#timeout#fail-silent#retry
Wrap OpenAI, Anthropic or Google Gemini clients in one line of code with a strict 1500ms AbortController timeout and automatic 5xx retry buffering.
How It Works Under the Hood
- •shdw.wrapClient(client) uses a lightweight JavaScript Proxy to observe .create(), .stream(), and .generateContent() calls without mutating your AI SDK client.
- •For standard responses and Server-Sent Events (SSE) streams, @shdwsdk/sdk normalizes input and output token counts in memory and queues an event on a non-blocking microtask.
- •Background network flushes use an AbortController strictly clamped to <= 1500ms. If a 5xx server error or network outage occurs and buffer capacity permits (< 450 events), failed batches are automatically unshifted back onto the buffer for retry.
How to Use It Step-by-Step
- 1Create an API key in Settings → Developer Settings & API Keys.
- 2Install @shdwsdk/sdk via npm, pnpm, yarn, or bun.
- 3Wrap your AI client instance with shdw.wrapClient() and use it normally across your application.
src/lib/ai.ts — Wrapping OpenAI & Anthropic
import OpenAI from "openai";
import { ShdwTelemetryClient } from "@shdwsdk/sdk";
const shdw = new ShdwTelemetryClient({
apiKey: process.env.SHDW_API_KEY!,
endpoint: "https://www.shdwsdk.ai/api/v1/ingest-telemetry",
defaultGridRegion: "eu-north-1", // or "us-west-2"
defaultWorkloadName: "Enterprise Support Copilot",
timeoutMs: 1500,
});
export const openai = shdw.wrapClient(new OpenAI());Related guides
- Interactive CLI Setup Wizard (npx @shdwsdk/sdk init / npx shdw-init)
- Layer 1: Zero-Touch Runtime AI-BOM Auto-Discovery & Zero-Knowledge Prompt Hashing
- Layer 2: RAG & Vector Database Auto-Instrumentation (shdw.wrapVectorStore)
- Layer 3: Static Manifest & CI/CD Auto-Scanner (@shdwsdk/sdk/scanner)
- Layer 4: Model Integrity & CycloneDX / SPDX Exporters
- Scope 3 Energy & Carbon Formula + 22 Global & European Data Center Regions
- EU AI Act Risk Classification & US NIST AI RMF 1.0 Assessment Matrix
- Buyer-Facing Public Trust Center (/trust/[slug]) & Embeddable HTML Badge
