Project Info

Clarity

Devpost

This project did not submit a demo video on Devpost.

Inspiration

"Our AI-powered customer support system was failing 40% of the time. We had no idea why." During a late-night debugging session, we realized something terrifying: our production AI was silently failing on thousands of customer emails. No error logs. No metrics. No way to debug. Just angry customers and a bleeding bank account. Traditional monitoring tools weren't built for LLM prompts. You can't just check CPU usage or error rates- you need to see: Why did GPT-5-nano classify this email wrong? Why are we spending $14,400/month on AI? Which prompt version is actually better? Why is latency spiking at 3 AM? We looked for a solution. Langsmith was too complex. Weights & Biases wasn't designed for production. Existing tools required hours of setup and still didn't answer our questions. So we built Clarity: Prompt observability that just works.

What it does

Clarity is a 2-line integration that gives you complete visibility into your LLM applications: For Developers For Everyone Else A user-friendly dashboard that shows: Real-time request monitoring - See every LLM call as it happens Automatic cost tracking - Know exactly what you're spending ($0.48 per email? Too much!) Instant replay - Re-run any request with different models/prompts Prompt versioning - Track performance across v1, v2, v3... Deep debugging - Full request/response logs with token breakdowns Performance analytics - Latency trends, success rates, model comparison Mock Demo We built SmartMail - a customer support AI that looks perfect... until it doesn't: Try billing email: "I was charged twice" → Works flawlessly Try technical email: "App keeps crashing" → Classification Failed Reveal: This isn't a broken demo- it's a real AI system failing 40% of the time Without Clarity: Developers have no idea why it's failing With Clarity: Instant debugging, root cause analysis, and fix deployment

How we built it

Architecture A full-stack observability platform in 48 hours: 1. Clarity SDK (@clarity/node) TypeScript SDK with strict mode for bulletproof types OpenAI wrapper - Intercepts chat.completions.create() Anthropic wrapper - Intercepts messages.create() Smart batching - Queues logs, flushes every 5 seconds Cost calculator - Hardcoded pricing for GPT-5, GPT-4o, Claude Opus/Sonnet/Haiku Auto-detection - Reads app name from package.json, environment from NODE_ENV Graceful shutdown - Flushes queue on process exit Zero dependencies - Just node-fetch for API calls 2. Web Dashboard (Next.js + React) Real-time log viewer - Server-sent events for live updates Cost analytics - Charts showing spend over time Replay engine - Re-run requests with different parameters Filtering system - By prompt ID, environment, status, date range Prompt comparison - Side-by-side v1 vs v2 metrics 3. SmartMail Demo (Next.js) Intentionally broken classifier (v1.2 fails on technical emails) Multi-model support - GPT-4o-mini, GPT-4o, Claude Sonnet Cost tracking - Shows real costs per email classification Integration showcase - Demonstrates Clarity SDK in action Tech Stack SDK: TypeScript 5.0, Node.js 20, Jest (31 passing tests) Web: Next.js 16, React, Tailwind CSS, Shadcn UI Demo: Next.js, OpenAI SDK 6.7.0, Anthropic SDK 0.67.0 Infra: Neon, PostgreSQL, Vercel (planned) Key Technical Achievements 1. Perfect TypeScript DX 2. Non-blocking Logging Logs never block your LLM calls Background queue with retry logic (max 3 attempts) Errors logged but never thrown Your AI keeps working even if Clarity is down 3. Smart Cost Calculation Model normalization: gpt-4o-2024-08-06 → gpt-4o Cached token support: (uncached × $2.50) + (cached × $1.25) Per-request cost tracking GPT-5 ready (estimated pricing included) 4. Prompt Version Management

Challenges we ran into

1. TypeScript Type Constraints Problem: Wrapping OpenAI/Anthropic clients broke type inference Solution: Generic wrappers + Object.defineProperty 2. The Streaming Problem OpenAI and Anthropic both support streaming responses. Our wrappers needed to handle both: 3. Cost Calculation Edge Cases Cached tokens: OpenAI's prompt caching reduces costs Model versioning: Handle gpt-4o-2024-08-06 as gpt-4o 4. Race Conditions in Logging Problem: Process could exit before logs flushed Solution: Graceful shutdown handlers 5. The "Demo Must Fail" Paradox SmartMail needed to fail convincingly without looking like our code was broken: Made v1.2 intentionally buggy (catches wrong keywords) Added clear UI states for "Classification Failed" Created realistic error messages Built in fallback behavior (shows error, doesn't crash) 6. SDK Version Compatibility Upgraded to latest SDKs mid-hackathon: OpenAI 4.0.0 → 6.7.0 (major breaking changes) Anthropic 0.20.0 → 0.67.0 (new message format) Had to refactor wrappers for new APIs All 31 tests still passing

Accomplishments we're proud of

1. The 2-Line Integration We obsessed over developer experience: Most observability tools require: Installing 5+ packages Configuring YAML files Adding instrumentation to every function Learning a complex API Clarity just works. 2. Zero TypeScript Errors Verified with: tsc --noEmit Clean build 31/31 unit tests passing Demo app compiles Full IntelliSense support 3. Production-Ready Cost Tracking Hardcoded pricing for 9 models across 2 providers: OpenAI: GPT-5, GPT-5-turbo, GPT-4o, GPT-4o-mini, GPT-4-turbo, GPT-4, GPT-3.5-turbo Anthropic: Claude Opus 4, Claude Sonnet 4, Claude Sonnet 3.5, Claude Haiku 3.5 Real-world accuracy: 4. The Clarity Demo Approach Built a demo that tells a story: Show perfect AI behavior → Audience relaxed Show failure → Audience thinks "oh no, bug!" Reveal it's intentional → Mind blown Switch to Clarity dashboard → Show the solution Debug in real-time → Prove it works This demo strategy makes Clarity's value instantly obvious. 5. Smart Defaults That Actually Work 6. Comprehensive Documentation Main README with quick start SDK README with full API docs Demo app README with setup guide Integration summary with test results Completion checklist (100% done!)

What we learned

1. TypeScript Generics Are Powerful Going from this: To this: 2. Developer Experience > Features We cut streaming support to focus on making the basic integration perfect: 2 lines vs 20 lines Zero config vs complex setup Auto-detection vs manual specification Type-safe vs error-prone The result: Clarity is easier to integrate than any competitor. 3. Observability Isn't Just Logging Users don't just want logs—they want answers: "Here are 10,000 request logs" "Your v1.2 classifier fails 40% of the time on technical emails" "Your v1.2 classifier fails 40% of the time on technical emails" "Total cost: $14,400/month" "Total cost: $14,400/month" "You're using GPT-4o for classification. Switch to GPT-4o-mini and save $11,000/month" "You're using GPT-4o for classification. Switch to GPT-4o-mini and save $11,000/month" "Request failed with status 400" "Request failed with status 400" "Input exceeded max tokens. Truncate to <4096 tokens" "Input exceeded max tokens. Truncate to <4096 tokens" 4. The Power of "Just Works" Every time we asked "should this be configurable?" we chose "no": App ID? Auto-detect from package.json Environment? Map from NODE_ENV Batching? 5 seconds is always right Shutdown? Handle automatically Less configuration = more usage. 5. Testing Prevents Disasters Mid-hackathon SDK upgrade could have broken everything: OpenAI 4.0 → 6.7 (major version jump) Anthropic 0.20 → 0.67 (3x version jump) But our 31 unit tests caught every breaking change: 6. Demos Should Tell Stories SmartMail isn't just a tech demo—it's a story: Setup: "Here's a working AI system" Conflict: "Oh no, it's failing!" Crisis: "40% of emails are being mishandled" Resolution: "Clarity shows us exactly why" Happy Ending: "Fixed in minutes, saving thousands" Stories > feature lists. 7. Rapid AI Integration Every developer we talked to said: "We're spending thousands on OpenAI" "We have no idea where the money goes" "Our AI fails randomly" "We can't debug it" This isn't a nice-to-have. This is a must-have.

What's next

Streaming Support Handle Server-Sent Events from OpenAI/Anthropic Log streaming tokens in real-time Calculate costs for partial responses Streaming Support Handle Server-Sent Events from OpenAI/Anthropic Log streaming tokens in real-time Calculate costs for partial responses More Providers Google Gemini wrapper AWS Bedrock support Cohere integration Mistral AI support More Providers Google Gemini wrapper AWS Bedrock support Cohere integration Mistral AI support Dashboard v2 Real PostgreSQL backend (currently mock data) User authentication Team collaboration features API key management Dashboard v2 Real PostgreSQL backend (currently mock data) User authentication Team collaboration features API key management Short Term (1-2 Months) Advanced Analytics Cost forecasting: "At this rate, you'll spend $50K next month" Anomaly detection: "Success rate dropped 20% in last hour" Model recommendations: "Switch to GPT-4o-mini for 80% cost savings" Advanced Analytics Cost forecasting: "At this rate, you'll spend $50K next month" Anomaly detection: "Success rate dropped 20% in last hour" Model recommendations: "Switch to GPT-4o-mini for 80% cost savings" Prompt Optimization A/B testing framework Statistical significance testing Automatic rollback on regression Gradual rollout (10% → 50% → 100%) Prompt Optimization A/B testing framework Statistical significance testing Automatic rollback on regression Gradual rollout (10% → 50% → 100%) Alerts & Notifications Slack integration Email alerts PagerDuty integration Custom webhooks Alerts & Notifications Slack integration Email alerts PagerDuty integration Custom webhooks Medium Term (3-6 Months) Python SDK from clarity import init, wrap_openai init(api_key=os.getenv('CLARITY_API_KEY')) client = wrap_openai(OpenAI()) Python SDK Browser SDK // Works in Next.js, React, Vue, vanilla JS import { wrapOpenAI } from '@clarity/browser'; Browser SDK Evaluation Framework Define test cases Run bulk evaluations Compare model performance Track quality metrics over time Evaluation Framework Define test cases Run bulk evaluations Compare model performance Track quality metrics over time Long Term (6-12 Months) Enterprise Features SSO / SAML authentication Role-based access control Audit logs SOC 2 compliance Enterprise Features SSO / SAML authentication Role-based access control Audit logs SOC 2 compliance Self-Hosted Option Docker deployment Kubernetes helm charts On-premise installation Air-gapped environments Self-Hosted Option Docker deployment Kubernetes helm charts On-premise installation Air-gapped environments AI Insights Automatic prompt improvement suggestions Cost optimization recommendations Quality regression detection Anomaly explanations AI Insights Automatic prompt improvement suggestions Cost optimization recommendations Quality regression detection Anomaly explanations The Vision Clarity becomes the default way to build with LLMs. Just like: Sentry for error tracking Datadog for infrastructure monitoring Stripe for payments Clarity for Prompt observability. Every AI application, from day one, integrates Clarity. Because flying blind isn't an option anymore. Try It Yourself SmartMail Demo Try these emails: "I was charged twice" (works) "App keeps crashing" (fails) Clarity Dashboard SDK Integration Impact For Developers: Debug AI failures in seconds (not days) Ship with confidence Optimize costs without guesswork For Businesses: 40% cost reduction through model optimization 95% success rate (up from 60%) Happy customers who get correct responses For The Market: $50B+ AI market 90% lack observability Early mover advantage Massive TAM Built With TypeScript & Node.js Next.js & React OpenAI SDK 6.7.0 Anthropic SDK 0.67.0 Tailwind CSS & Shadcn UI Jest for testing

Analysis

Compare with all teams

View

Metric

Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.

Technology

Found in codeClaimed only
  • AnthropicIn code
  • CSSIn code
  • JavaScriptIn code
  • Next.jsIn code
  • OpenAIIn code
  • ReactIn code
  • SQLIn code
  • Tailwind CSSIn code
  • TypeScriptIn code

9 of 9 appear in the indexed code.

AI coding agents

No AI coding agent signals were found in this repository.

Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.

Codebase size

Source size

514 KB

Source files

110

Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.

0 stars