agentskit.js
Security

Rate limiting

Token bucket per user / IP / key. Works with any adapter.

import { createRateLimiter } from '@agentskit/core/security'

const limiter = createRateLimiter({
  capacity: 10,
  refillPerSecond: 1,
  keyBy: (req) => req.userId,
})

app.post('/chat', async (req) => {
  const { allowed, retryAfterMs } = await limiter.take(req)
  if (!allowed) return new Response('Too Many Requests', { status: 429, headers: { 'retry-after': `${Math.ceil(retryAfterMs / 1000)}` } })
  // ... run agent
})

Storage

  • In-memory (default) — single-host.
  • BYO store via { get, set } — Redis / Upstash / any K/V for multi-host.
✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page