Smart Routing
Sends each request to the most cost-effective AI model that can do the job well, deciding instantly for every prompt.
Measure where AI spend goes, then apply approved optimizations with fallback and traceable savings.
Traffic is sent through routing, cache, trim, downshift, and prompt compression mechanisms. Batching is a separate async workflow for non-urgent jobs. Each lever is auditable, individually togglable, and measured against the evidence appropriate to the workload.
Sends each request to the most cost-effective AI model that can do the job well, deciding instantly for every prompt.
Saves past AI answers and reuses them whenever a new request means the same thing, even if it's worded differently.
Cleans up prompts in real time by stripping out repeated text, extra whitespace, and unnecessary history before sending.
Rewrites long system instructions into permanently shorter versions to cut token costs, requiring human review before going live.
Uses test history to safely move routine tasks to cheaper models, testing changes on a small scale first with instant rollback.
Groups non-urgent requests together in the background to process them at heavily discounted batch rates.
Three ways to connect. Each provides a different level of security and control. The SDK wrapper is recommended for production traffic, the base URL is fastest for evaluation, and the metadata-only path is strictest for sensitive workloads.
The OpenAI wrapper sends healthy traffic through Varsten and falls back direct-to-provider on Varsten-origin failures before provider output starts. Your provider key stays local for fallback.
import { VarstenOpenAI, VarstenTrace } from "@varsten/openai";
const client = new VarstenOpenAI({
varstenApiKey: process.env.VARSTEN_API_KEY,
openaiApiKey: process.env.OPENAI_API_KEY,
onFallback: (event) => {
console.warn("varsten fallback", event.reasonCode);
},
});
const trace = new VarstenTrace();
await client.chat.completions.create(
{
model: "gpt-4o-mini",
messages,
},
{
varsten: trace.metadata({
feature: "support_agent",
taskType: "classification.intent",
customerId: "cust_123",
}),
},
);Opportunity estimates are free. Paid savings use an accepted evidence method—such as direct avoided cost, holdback comparison, or approved replay—with applicable overhead subtracted before fees are calculated.
Connect via Quick Eval or Metadata Only to audit your live traffic and map out estimated savings, with no behavior-changing optimization applied.
Unlocks the optimization engine: inline routing, cache, trim, compression, and downshift, plus async batching for eligible jobs. Pricing is capped at 25% of verified savings.
For custom pricing that doesn't scale with your bill,
we negotiate a rate and fee cap.