Skip to content

Instantly share code, notes, and snippets.

@sohang3112
Created May 13, 2024 12:05
Show Gist options
  • Save sohang3112/fc1f831334f97b6d96bbc49ef819e09e to your computer and use it in GitHub Desktop.
Save sohang3112/fc1f831334f97b6d96bbc49ef819e09e to your computer and use it in GitHub Desktop.
Openai notes - GPT calling
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