Examples Gallery

Real-World Examples

Copy-paste ready examples for common use cases. Real savings: 78.6% on RAG, 52.3% on chat history, 42.7% on structured data.

Customer Support Bot

Reduce token costs by 52.3% in customer support chatbots

-52.3%
Token Savings
import { YAVIQClient } from '@yaviq/sdk';

const client = new YAVIQClient(process.env.YAVIQ_API_KEY);

// Compress chat history for support bot
const messages = [
  { role: "user", content: "I can't log in" },
  { role: "assistant", content: "Let me help you..." },
  { role: "user", content: "I forgot my password" },
  { role: "assistant", content: "I'll reset it..." }
];

const result = await client.compressHistory(
  messages,
  "What should I do?",
  { mode: "balanced" }
);

console.log(result.final_answer);
console.log(`Saved ${result.metrics.final_total_savings_percent}`);