# Deadpipe > AI optimization platform for improving performance, reducing costs, and preventing issues in production. ## What Deadpipe Does Deadpipe answers one question: "Is this prompt still behaving safely?" - **Automatic Baselines**: Rolling baselines for every prompt (latency p95, token distributions, schema pass rates) - **Drift Detection**: Alerts when latency spikes, token counts shift, or schema validation drops - **Schema Validation**: Pass your Pydantic/Zod model and validate every LLM output - **Hallucination Proxies**: Track refusals, empty outputs, JSON parse failures, enum violations - **Change Tracking**: Hash prompts, system prompts, and tool schemas to correlate changes with performance - **Multi-Provider**: Supports OpenAI, Anthropic, Google (Gemini), Mistral, Cohere ## Quick Start ### Python ```bash pip install deadpipe export DEADPIPE_API_KEY="dp_your_api_key" ``` ```python from deadpipe import wrap from openai import OpenAI # Universal wrap() - wrap once with app context client = wrap(OpenAI(), app="my_app") # Pass prompt_id per call to identify each prompt response = client.chat.completions.create( prompt_id="my_agent", model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello!"}] ) # → Automatically captures: latency, tokens, cost, schema validation ``` ### Node.js / TypeScript ```bash npm install deadpipe export DEADPIPE_API_KEY="dp_your_api_key" ``` ```typescript import { wrap } from 'deadpipe'; import OpenAI from 'openai'; // Universal wrap() - wrap once with app context const client = wrap(new OpenAI(), { app: 'my_app' }); // Pass promptId per call to identify each prompt const response = await client.chat.completions.create({ promptId: 'my_agent', model: 'gpt-4o-mini', messages: [{ role: 'user', content: 'Hello!' }] }); // → Automatically captures: latency, tokens, cost, schema validation ``` ## Schema Validation Example ### Python with Pydantic ```python from deadpipe import wrap_openai from pydantic import BaseModel from openai import OpenAI class RefundResponse(BaseModel): order_id: str amount: float status: str client = wrap_openai(OpenAI(), app="my_app", schema=RefundResponse ) # Pass prompt_id per call response = client.chat.completions.create( prompt_id="checkout_agent", model="gpt-4", messages=[...] ) # → Validates every output against RefundResponse # → Tracks schema pass rates over time ``` ### Node.js with Zod ```typescript import { wrapOpenAI } from 'deadpipe'; import { z } from 'zod'; const RefundSchema = z.object({ orderId: z.string(), amount: z.number(), status: z.string() }); const client = wrapOpenAI(new OpenAI(), { app: 'my_app', schema: { validate: (data) => { const result = RefundSchema.safeParse(data); return { success: result.success, data: result.success ? result.data : undefined, errors: result.success ? undefined : result.error.errors.map(e => e.message) }; } } }); // Pass promptId per call const response = await client.chat.completions.create({ promptId: 'checkout_agent', model: 'gpt-4', messages: [...] }); ``` ## Key Features ### Fail-Safe Design - SDK never blocks your LLM calls - All telemetry sent asynchronously - If Deadpipe is down, your app continues working normally ### What Gets Captured Automatically - Request/response latency - Time to first token (streaming) - Input/output tokens - Estimated cost - Model and provider - Schema validation results - JSON parse success/failure - Empty output detection - Refusal detection - Prompt hash, tool schema hash, system prompt hash ### Drift Detection Anomalies are detected when: - Latency exceeds p95 + 2σ - Token count deviates > 3σ from mean - Schema validation fails (when baseline > 95%) - Empty outputs increase - Refusal rate spikes ## Supported Providers | Provider | Python | Node.js | |----------|--------|---------| | OpenAI | `wrap_openai()` | `wrapOpenAI()` | | Anthropic | `wrap_anthropic()` | `wrapAnthropic()` | | Google (Gemini) | `wrap_google_ai()` | `wrapGoogleAI()` | | Mistral | `wrap_mistral()` | `wrapMistral()` | | Cohere | `wrap_cohere()` | `wrapCohere()` | Or use the universal `wrap()` function which auto-detects the provider. ## Links - Documentation: https://deadpipe.com/docs - Sign up: https://deadpipe.com/signup - Dashboard: https://deadpipe.com/dashboard - Blog: https://deadpipe.com/blog ## Contact Website: https://deadpipe.com