# AI response cache

> Model responses cached by a key the application derives from the request, with a TTL capped by maxTtl, hit counts and a purge of expired entries; only the service role reads and writes it.

- Category: AI
- Module: `ai-cache`
- Modes: `managed`
- Docs: https://bettersupabase.com/docs/blocks/ai-cache
- Page: https://bettersupabase.com/blocks/ai-cache

## Install

```bash
npx better-supabase add ai-cache
```

## Configure

Add the block to `better-supabase.config.ts`:

```ts
import { defineConfig } from "better-supabase/config";

export default defineConfig({
  blocks: {
    // Modes: "managed". The default is "managed".
    "ai-cache": { mode: "managed" },
  },
});
```

## Client

The block has no React entry yet. Its server-side TypeScript is in `better-supabase/blocks/ai-cache`.
