This is how I did it - https://github.com/openai/codex/blob/main/docs/config.md#mod...
I have it go to openrouter, and then you just export the API key and run codex, works smoothly.