Skip to main content

llm_recorder

llm_recorder is a basic observability and debugging tool for language model apps. It stores interactions with LLMs in a local directory and provides a way to replay them. It is particularly useful for debugging chained LLM calls.

With llm_recorder, you can:

  • Save every request/response pair to a directory.
  • Replay part of previously recorded interactions instead of making live LLM calls.

You can use it to:

  • Inspect LLM responses and requests that lead to them
  • Record an execution path that leads to a specific response and then replay it and see how the application behaves downstream
  • Modify the recorded responses before replaying them

Installation

pip install llm_recorder

Getting Started

For a quick start use enable_replay_mode; it monkey patches litellm to record and replay responses.

llm_recorder records any calls to litellm.completion and their responses and stores them in the directory specified by store_path.

Specify replay_count to replay previously recorded interactions (by default no interactions are replayed). Once the replayed interactions are exhausted, llm_recorder falls back to live LLM calls.

The store_path is cleaned up at the start of each run, but interactions from the previous run are read before that cleanup.

Basic Example

from llm_recorder import enable_replay_mode

import litellm


enable_replay_mode(store_path="saves")

print("After:", litellm.completion.__name__)

# Now just use litellm as usual:

response = litellm.completion(
    model="openai/gpt-4o",
    messages=[{ "content": "Hello, how are you?","role": "user"}]
)

Then have a look at the 'saves' directory to see the recorded interactions.

Chained Calls Example

See examples/chained_calls.py for an example of how to use llm_recorder to record and replay chained LLM calls. I saved the first interaction in examples/saves/chained_calls/ and the example replays it before making live calls.

Advanced Usage

For more fine-grained control instantiate and use the LiteLLMRecorder class directly. See examples/direct_recorder.py.

Limitations

  • Direct support for SDKs (not through litellm) and the recording HTTP client is experimental.
  • Only supports synchronous calls.

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub.

License

This project is licensed under the MIT License.

Metadata

Release files for llm-recorder 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-recorder 0.1.0
File Size Uploaded Provenance
llm_recorder-0.1.0.tar.gz 11.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-recorder 0.1.0
File Interpreter ABI Platform
llm_recorder-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / llm_recorder-0.1.0.tar.gz

Download URL llm_recorder-0.1.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fa09c018911a94a08ee365feedf3995cc61bf2a066a5ef0e7a737367679dc0c0
BLAKE2b-256 checksum
How to use checksums
f3ae8a9927d3cd12d793425cd788ff8dbdbcb4810ad44f54430e31d14488a955
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Release files / llm_recorder-0.1.0-py3-none-any.whl

Download URL llm_recorder-0.1.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ebe31349ce1aff4f4e036d0b75ecf8532c30c64058760f870947cd7105d4b61
BLAKE2b-256 checksum
How to use checksums
3ae3db958919ba296d538ea4b3895bf5e587d7b53cc6964a449c53442a8bfcec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Security for llm-recorder 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page