Thskyshield for LLM Apps

Per-user budgets.
No wallet-drain.

Wrap your LLM calls with two SDK methods. Before the request executes, we atomically check and reserve the user's budget in Redis. If they're over the limit, the API call never happens — no tokens burned, no cost incurred.

Under 10ms pre-call check
Per-user and per-plan limits
Atomic Lua — no race condition
Fail-open by design
Two-Phase Enforcement

Before the call fires. Every time.

Most spend-tracking tools log after the fact — they can't prevent an overrun. Thskyshield checks and reserves budget atomically before the LLM API call is made.

shield.check() — Phase A
Atomic budget reservation

Before the request executes, the SDK checks the user's remaining budget via an edge endpoint. If they're under the limit, the estimated cost is atomically reserved in Redis. If over — blocked instantly. Under 10ms.

shield.log() — Phase B
Actual cost reconciliation

After the LLM responds, the SDK logs the real token cost. Redis is reconciled atomically. Supabase gets a permanent record: model, cost, user, plan, outcome.

Naive approach — has a race condition
// ❌ Two concurrent requests can both pass
const spend = await db.getSpend(userId);
if (spend < limit) {
// Both reach here simultaneously
await callLLM(); // 💸 budget exceeded
}
Thskyshield — atomic Lua, no race
// ✅ Lua script reserves cost atomically
const { allowed } = await shield.check({
externalUserId: userId,
model: 'gpt-4o',
estimatedTokens: { input: 500, output: 200 },
});
if (allowed) await callLLM(); // ✓ safe
60-Second Setup

One npm install.
Zero app rewrites.

Add shield.check() before and shield.log() after. Everything else stays the same.

  • Works with GPT-4o, Claude, Gemini, or any model
  • Per-user and per-plan budget limits in the dashboard
  • Fail-open: if our API is down, your app stays up
  • Real-time spend dashboard + full audit log
Read the full docs
setup.ts
// npm install @thsky-21/thskyshield

import { Thskyshield } from '@thsky-21/thskyshield'

const shield = new Thskyshield({
  siteId: process.env.THSKYSHIELD_SITE_ID!,
  apiKey:  process.env.THSKYSHIELD_KEY!,
})

// Before the LLM call
const { allowed, requestId } = await shield.check({
  externalUserId: userId,
  model:          'gpt-4o',
})
if (!allowed) return res.status(429).json({ error: 'Budget exceeded' })

// After the LLM call
await shield.log({ requestId, externalUserId: userId, model: 'gpt-4o', tokens })

Start protecting your LLM app.

Free tier. No credit card. Deploy in 60 seconds.