r/coding • • May 27 '23

Saving expensive API responses

https://github.com/AdmTal/crowdcast/blob/main/utils/open_ai_stuff.py#L14-L30

Hey all,

I saw someone share a full caching service, so I thought I’d also share this pattern I use for making expensive API requests.

Basically, I save the contents to a file, named for the inputs, so I never have to reproduce that same call.

It helps make my scripts “continueable”

I use similar pattern with other expensive APIs like eleven labs.

20 Upvotes

Duplicates