Skip to main content

LLM Warehouse

🏠 Auto-capture OpenAI and Anthropic LLM calls for warehousing

A lightweight Python library that automatically logs all your OpenAI and Anthropic API calls to various storage backends, including your own Flask app, Supabase, or local files.

🚀 Quick Start

Installation

pip install llm-warehouse

Or for the latest development version:

pip install git+https://github.com/sinanozdemir/llm-warehouse.git

Basic Usage

For automatic patching on import, set environment variables:

export LLM_WAREHOUSE_API_KEY="your-warehouse-api-key"
export LLM_WAREHOUSE_URL="https://your-warehouse.com"

Then just import any LLM library AFTER importing this package - logging happens automatically:

import llm_warehouse  # BEFORE openai or anthropic

import openai  # Automatically patched!
# or
import anthropic  # Automatically patched!

Sample usage:

import llm_warehouse

# Now use OpenAI/Anthropic normally - all calls are automatically logged!
import openai
client = openai.Client()
response = client.chat.completions.create(
    model="gpt-4.1-mini",
    messages=[{"role": "user", "content": "Hello!"}]
)

📊 What Gets Logged

  • Request data: Model, messages, parameters
  • Response data: Completions, token usage, timing
  • Metadata: Timestamps, SDK method, streaming info
  • Errors: API errors and exceptions

🔧 Configuration Options

🛡️ Environment Variables

Variable Description
LLM_WAREHOUSE_API_KEY Your warehouse API token (enables auto-patching)
LLM_WAREHOUSE_URL Your warehouse URL

🔄 Programmatic Control (for advanced users)

import llm_warehouse

# Enable logging
llm_warehouse.patch(warehouse_url="...", api_key="...")

# Disable logging
llm_warehouse.unpatch()

# Check status
if llm_warehouse.is_patched():
    print("LLM calls are being logged")

🏗️ Backend Options

API Warehouse Backend

Use with the included API (recommended):

llm_warehouse.patch(
    warehouse_url="https://your-warehouse.com",
    api_key="your-warehouse-api-key"
)

Supabase Backend

Direct integration with Supabase:

llm_warehouse.patch(
    supabase_url="https://your-project.supabase.co",
    supabase_key="your-supabase-anon-key"
)

Local File Backend

For development and testing:

llm_warehouse.patch(log_file="llm_calls.jsonl")

📦 Features

  • ✅ Zero-configuration: Works out of the box with environment variables
  • ✅ Multiple backends: Flask warehouse, Supabase, local files
  • ✅ Async support: Full async/await compatibility
  • ✅ Streaming support: Captures streaming responses
  • ✅ Error handling: Logs API errors and exceptions
  • ✅ Minimal overhead: Designed for production use
  • ✅ Thread-safe: Works in multi-threaded applications

🧪 Development

git clone https://github.com/sinanozdemir/llm-warehouse.git
cd llm-warehouse/llm-warehouse-package
pip install -e ".[dev]"

Run tests:

pytest

Format code:

black llm_warehouse/
isort llm_warehouse/

📝 License

MIT License - see LICENSE file for details.

Metadata

Release files for llm-warehouse 0.1.5

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-warehouse 0.1.5
File Size Uploaded
llm_warehouse-0.1.5.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-warehouse 0.1.5
File Interpreter ABI Platform
llm_warehouse-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 28.3 kB

Release files / llm_warehouse-0.1.5.tar.gz

Download URL llm_warehouse-0.1.5.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ab1980e9c465c5f7ee74cd9ebf48770ca896617e7f3ff574d838d7318943064f
BLAKE2b-256 checksum
How to use checksums
88acce09dfe122682572b8c1c703a395296c28a727cffc464e9be5e8cd4ace47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / llm_warehouse-0.1.5-py3-none-any.whl

Download URL llm_warehouse-0.1.5-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f8ae5d226456b644b8c3e87730de316ba91ee2acbb2ec2b5a830f568f1cd61a
BLAKE2b-256 checksum
How to use checksums
b10f678400feb94ed30ff421dd429365c2fe1214e597a20bf5650b6b184c3b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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