Created
May 13, 2024 12:05
-
-
Save sohang3112/fc1f831334f97b6d96bbc49ef819e09e to your computer and use it in GitHub Desktop.
Openai notes - GPT calling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import openai | |
# Call GPT | |
os.environ['OPENAI_API_KEY'] = 'PUT-OPENAI-API-KEY-HERE' | |
client = openai.OpenAI() | |
prompt = "Say Hi!" # put instructions to GPT here | |
gpt_response = client.chat.completions.create( | |
model="gpt-3.5-turbo", | |
messages=[{"role": "user", "content": prompt}], | |
stream=False, | |
) | |
gpt_response_message = gpt_response.choices[0].message.content | |
print(gpt_response_message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment