I would love to convert this, just to stick it to Python.
I’m not a fan of it, however given the use of vectors and a range of “modules”, I would just grab the bindings and cave in.
A pure rewrite would utilize AVX/AVX2 or the SSE instructions (with CPU vendor detection of course). So that alone is worth considering if desiring a scratch implementation in C. Pelles has vector support, you will find this in the project settings.
Basically, you would need the API documentation and the rest is up to the C programming to align with the OpenAI API documentation.
It looks like some work outside of the Python C bindings.