Using the Chat-GPT-4 API to Generate Code Documentation

I provide a code snippet to Chat GPT, and then it returns documentation in the template I desire for that code. Does anyone know the best way to do this? I’m only using the API, and it seems to be working well. Can anyone also recommend a way to reduce tokens on input? I’m using JavaScript and Node.js.