ChatGPT will “hallucinate” and happily give you non-facts as if they were facts. Best to stick with the docs. They’ve got examples for most modern languages …
Docs…
API docs…
Sounds like you want completions, which would be…
post https://api.openai.com/v1/completions
Then you would need to pass it a model like text-davinci-003.
Hope this helps.
(And welcome to the community!)