import openai openai.api_key = "YOUR_API_KEY_HERE" # replace this with your own API key def generate_text(prompt): response = openai.Completion.create( engine="text-davinci-002", prompt=prompt, max_tokens=1024, n=1, stop=None, temperature=0.5, ) return response.choices[0].text.strip() # Example usage: prompt = "Hello, ChatGPT! How are you doing today?" generated_text = generate_text(prompt) print(generated_text)