Build a Chat Messages Array
Safe Prompt Template Filling
Token-Budgeted Chat History Trimming and Compaction
Streaming and Structured Output
Parse Chunked SSE Model Stream
Validated Structured Output With Retry Feedback
Incremental Streaming JSON Object Parser
Estimate Request Tokens and Dollar Cost
Resilient LLM Client With Backoff and Fallback
Per-Tenant Daily Token Budget Router
Semantic Cache with Similarity Threshold and TTL
RAG Retrieval With Metadata Filters and Citations
PII Redaction With Placeholder Restore
Regression Eval Harness with LLM-as-Judge