from requests import post url = 'https://api.openai.com/v1/chat/completions' headers = {"Authorization": 'Bearer sk-proj-oj4RjkNKhQoOFZAfCzmsT3BlbkFJCQU6j9rS1qCrOgaKjZOK'} def ai(prompt): data = {"model": "gpt-4o-mini", "messages": [{"role": "user", "content": prompt}]} result = post(url, headers=headers, json=data).json() return (result['choices'][0]['message']['content']) def print_ai(prompt): print(ai(prompt))
print_ai('gimme a random word')
Serendipity.
name = input('Gimme a name') print_ai(f'Gimme hilarious sentance about {name}')
Scott tried to impress everyone at the party by juggling pineapples, but he ended up starting a fruit salad revolution instead!