AI · api.justeita.com
LiveChat API
Multi-tenant streaming chat Worker for live origins.
- Hono
- Cloudflare Workers
- KV
- TypeScript
- OpenAI-compatible
- Streaming
api.justeita.com/health

Frames

Architecture · Origin → Worker → tenants

Request path · guards + stream
Overview
Central Hono Worker at api.justeita.com. Origin maps to per-site prompts. Shared @portfolio/chatbot package handles injection pre-filter, rate limits, payload caps, work-request refusal on portfolio, stream proxy with em-dash strip, and mid-stream sanitize. Runtime model config from KV with secret-held API keys and a fallback provider path.
Problem
Each showcase site needed streaming AI without four separate backends, four key stores, or copy-pasted security filters. Portfolio also needed to refuse free work requests while demos stay helpful brand concierges.
Approach
One Worker, one Origin map, one shared handler factory. Tenant prompts live next to the Worker; clients only ship thin useChat wrappers. Model routing is config (KV → env → defaults) so keys and model swaps do not require redeploying every site.
Features
Tenant map
Production and local origins resolve to configured tenants. Unknown origins fall back carefully; empty allowlist fails closed.
Shared package
@portfolio/chatbot is zero runtime deps: types, security, rate-limit, handler factory, React useChat.
Work detection
Portfolio tenant only: TASK_PATTERNS refuse coding and homework-style asks before the model runs, then redirect to portfolio topics.
Runtime AI config
KV provider object sets primary and fallback baseUrl/model. API keys only in secrets or .dev.vars.
Live
Try live →Proof
- Injection pre-filter, payload caps, and origin allowlist before stream.
- Em dash stripped on stream deltas; mid-stream sanitize on assistant text.
- Portfolio work detection never bills the model for refused tasks.
- Health endpoint for ops smoke; secrets never land in KV provider JSON.
Tradeoffs
- In-memory rate limit is per isolate, not global durable quota.
- Sites depend on one chat origin; CSP must allow that host.
- Prompt quality is the product surface; stale prompts under-sell live demos.
Need an AI system, a streaming chat backend, or a local-first product. Email is fastest.
Email brief