Complete SDK with 9 core features. Get started in minutes with Node.js, Python, or CLI. Real savings: up to 78.6% on RAG, 42.7% on structured data, 52.3% on chat history.
Installation
npm install @yaviq/sdkexport YAVIQ_API_KEY="your_api_key_here"Or create a .env file:
YAVIQ_API_KEY=your_api_key_here
YAVIQ_ENDPOINT=http://localhost:8080 # Optionalimport { optimizeAndRun } from "@yaviq/sdk";
// Optimize + Run LLM in one step
const result = await optimizeAndRun({
input: chatHistory,
model: "gpt-4"
});
console.log(result.final_answer);
console.log(`Saved ${result.metrics.input_token_savings}`);
// You keep your LLM key. YAVIQ only optimizes context.All Features
Everything you need to optimize LLM costs
Compress prompts with auto-format detection
import { YAVIQClient } from '@yaviq/sdk';
const client = new YAVIQClient(process.env.YAVIQ_API_KEY);
const result = await client.optimize("Your prompt here", {
mode: "balanced",
format: "auto"
});
console.log(result.optimized);
console.log(`Saved ${result.tokensSaved} tokens (${result.compression}%)`);Advanced Usage
Real-world examples for complex use cases
API Key Setup
Go to your dashboard and create an API key under API Keys
Never commit API keys to version control. Use environment variables or secrets managers.
# .env file (never commit this!)
YAVIQ_API_KEY=your_api_key_here
YAVIQ_ENDPOINT=http://localhost:8080 # Optionalimport boto3
secrets = boto3.client('secretsmanager')
api_key = secrets.get_secret_value(
SecretId='yaviq/api-key'
)['SecretString']# Set in Vercel dashboard under Settings > Environment Variables
# Access via process.env.YAVIQ_API_KEYStart optimizing your LLM costs today. Get your API key and start saving tokens in minutes.