Metadata-Version: 2.4
Name: cached-openrouter
Version: 0.1.0
Summary: OpenRouter client that records and replays API responses — no key needed after caching
Project-URL: Source, https://github.com/danguetta/cached_openai
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: openai

# cached-openrouter

OpenRouter client that records and replays API responses. Based on [cached_openai](https://github.com/danguetta/cached_openai) by Daniel Guetta.

## Install

```
pip install cached-openrouter
```

## Usage

```python
import cached_openrouter

# Step 1 — record real API calls
client = cached_openrouter.OpenAI(api_key='sk-or-v1-...')
resp = client.chat.completions.create(
    model    = 'openai/gpt-4o-mini',
    messages = [{'role': 'user', 'content': 'What is a cache?'}],
)
print(resp.choices[0].message.content)

# Step 2 — save to a file
cached_openrouter.materialize('course.cache')

# Step 3 — load and serve with no API key
student = cached_openrouter.load('course.cache')
resp = student.chat.completions.create(
    model    = 'openai/gpt-4o-mini',
    messages = [{'role': 'user', 'content': 'What is a cache?'}],
)
print(resp.choices[0].message.content)  # served from cache instantly
```
