gptclass (pypi): A Python class that does what you need
Keywords: gpt|openai|code-generations