OpenRouter client that records and replays API responses — no key needed after caching
Project description
cached-openrouter
OpenRouter client that records and replays API responses. Based on cached_openai by Daniel Guetta.
Install
pip install cached-openrouter
Usage
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cached_openrouter-0.1.0.tar.gz.
File metadata
- Download URL: cached_openrouter-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee62c11e395de1b346753cf258ac9ff4831a80a327d1062d7b5a3bd3830c93a7
|
|
| MD5 |
06abe1e6c4be007da9140c407bcbcf84
|
|
| BLAKE2b-256 |
c44ab7792f14bad8e6aebacc3486737ac22d98e2d09cf0c3f6a7e9420bc42b95
|
File details
Details for the file cached_openrouter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cached_openrouter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48b7ab2b36c9c4268d01316b38707d427afc098fce5c70f7ba71645a5dda85b1
|
|
| MD5 |
9165d99c88ab933b3da02d0330767229
|
|
| BLAKE2b-256 |
2468959b47776c25c60c30fa9d964dfa528ce752ecf81f4ed0057c14e1e60613
|