# If it's gonna steal our jobs, we may as well learn how to use it ;)
# Before jumping into docs, below is the cost of chatgpt
# The ChatGPT API is priced at $0.002 per 1000 tokens or approximately 750 words.
# Here is the most basic python example to show it is not as hard as you may think
import openai
openai.api_key = "YOUR_API_KEY"
completion = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
temperature = 0.8,
max_tokens = 2000,
messages = [
{"role": "system", "content": "You are a funny comedian who tells dad jokes."},
{"role": "user", "content": "Write a dad joke related to numbers."},
{"role": "assistant", "content": "Q: How do you make 7 even? A: Take away the s."},
{"role": "user", "content": "Write one related to programmers."}
]
)
print(completion.choices[0].message)
# Here is a complete guide if you want more in python -> https://www.makeuseof.com/chatgpt-api-complete-guide/
# Here is an example in node.js -> https://www.udemy.com/course/getting-started-with-chatgpt-api/learn/lecture/36839456#overview
# Here is an example in springboot -> https://www.youtube.com/watch?v=HlDkuFy8xRM