For what it's worth, there's already a free Raycast extension that lets you supply your own OpenAI key which lets you do this pretty easily. Wherever possible, I lean towards the BYOK (bring your own key approach).
https://github.com/raycast/extensions/tree/99c7c7c4fa02afba9...