Since gpt2 does not appear to be deployed at this time, I will explain using a deployed model. Samples for Python, JavaScript, and curl can be obtained in the following manner.