API Reference

Code examples in 8 languages. Copy and paste into your project.

JavaScript
const response = await fetch("https://tokensave.vercel.app/api/proxy", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    provider: "anthropic",
    apiKey: "your-key",
    messages: [{ role: "user", content: "Hello" }]
  })
});
const data = await response.json();
console.log(data);

All Endpoints

POST/api/proxySend a single AI request through the optimization pipeline
POST/api/batchProcess up to 50 prompts in a single request
POST/api/trim-contextTrim old messages from long conversations
GET/api/proxyCheck API status and version
GET/api/statsGet usage statistics and recent logs
POST/api/generate-keyGenerate or rotate your TokenSave API key
POST/api/analyticsSubmit anonymous usage stats from the SDK