Status: [UNTESTED] Endpoints found: https://litellm.local/v1/chat/completions Source: https://github.com/tonyweckstrom1987/llm-cassette **English** | [Suomi](README.fi.md) # llm-cassette [![CI](https://github.com/tonyweckstrom1987/llm-cassette/actions/workflows/ci.yml/badge.svg)](https://github.com/tonyweckstrom1987/llm-cassette/actions/workflows/ci.yml) ![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg) Record the responses of your LLM calls once and replay them in tests. Tests become fast, free and stable in CI, and they need no API key. Record/replay for `fetch`-based LLM clients (VCR-style). It wraps `fetch`, stores responses in a JSON file, and replays them in tests. Default mode is `replay`, which never touches the network. Request headers (e.g. `Authorization`) are never stored. **Tech:** TypeScript, Node.js 22/24, vitest. No runtime dependencies. ## Installation ```bash npm install --save-dev @tonyweckstrom/llm-cassette ``` Node 22.12+ or 24. No runtime dependencies. (The name is scoped because `llm-cassette` is already published on npm by someone else: it is a different tool.) ## Usage ```ts import { cassetteFetch } from "@tonyweckstrom/llm-cassette"; const fetchWithCassette = cassetteFetch({ path: "test/cassettes/general.json" }); // Give this to your LLM client as its fetch function: const res = await fetchWithCassette("https://litellm.local/v1/chat/completions", { method: "POST", headers: { authorization: `Bearer ${process.env.LLM_API_KEY}` }, body: JSON.stringify({ model: "m", messages: [{ role: "user", content: "Hi" }] }), }); ``` Recording needs `record` mode (the default `replay` mode throws `CassetteMissError` when there is no recording). After that, runs replay the recorded responses: ```bash LLM_CASSETTE_MODE=record npm test # once, with a real key: records into the cassette npm test # normally: replays, no network ``` Commit the cassette files to the repository. CI then replays the same responses at no cost. ## Modes | Mode | What it does | | --- | --- | | `replay` (default) | Replays the recording. If there is n