You just have to use the GPT3 API provided by OpenAI that ChatGPT is based on. I've done it but it's not as honed in as theirs which can reformat code (using their Codex API) and ChatGPT has other filters that try to make it more moral and watered