Inspiration
AI-powered applications rely on external model APIs, but understanding their real operating costs can be difficult. Developers often need to inspect multiple dashboards and logs to understand which models, endpoints, or requests are driving spending, latency, and errors.
TokenWatcher was created to bring this information into one developer-friendly observability platform, making AI application usage easier to monitor and understand.
What it does
TokenWatcher is an open-source AI cost and observability platform.
Developers can integrate its TypeScript SDK into an application to capture request telemetry, including model usage, token consumption, estimated costs, latency, and errors.
The backend processes and stores telemetry in PostgreSQL. A web dashboard presents usage analytics and request logs, with real-time updates delivered through Server-Sent Events.
The platform also includes reporting, cost forecasts, recommendations, AI-powered insights, and Telegram-based access to analytics.
How we built it
TokenWatcher uses a modular TypeScript-based architecture:
- Backend: Node.js, Express, TypeScript, and PostgreSQL.
- Frontend: React, Vite, React Query, Tailwind CSS, and shadcn/ui.
- SDK: TypeScript SDK with batching, bounded queueing, retries, and shutdown flushing.
- Real-time updates: Server-Sent Events.
- Messaging integration: Telegram Bot API and OpenClaw.
- AI capabilities: Gemini-powered insights and recommendations.
- Agent capabilities: ERC-8004 agent identity and x402-protected endpoints on GOAT Mainnet.
The dashboard and Telegram integration use the same workspace-scoped telemetry data.
Challenges
A major engineering challenge was building a telemetry pipeline that could collect application data reliably without disrupting the application being monitored.
Other challenges included designing SDK batching and retry behaviour, handling authentication and API keys, maintaining workspace isolation, storing telemetry consistently, and delivering real-time updates.
Integrating external services also required careful handling of communication boundaries and access to workspace-specific data.
Accomplishments
- Developed an open-source AI observability platform.
- Built a dedicated TypeScript telemetry SDK.
- Implemented a backend ingestion pipeline backed by PostgreSQL.
- Created a real-time analytics dashboard using Server-Sent Events.
- Added reporting, forecasting, recommendations, and AI-powered insights.
- Integrated Telegram-based analytics access.
- Added agent identity and payment-protected agent capabilities.
What we learned
Building TokenWatcher strengthened our understanding of backend system architecture, SDK design, telemetry pipelines, database design, authentication, event-driven communication, and real-time interfaces.
It also provided practical experience integrating AI capabilities and external services into a larger software system.
