How to respect OpenAI’s rate limits in Rails

As it turns out, OpenAI's rate limits are a little more complicated than other APIs.