I am experiencing the following error message: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
The API Key is correct.
Does anybody how to solve this?
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("API KEY"),
)
# Call the GPT API
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": context}, #deleted context variable from this post
],
max_tokens=max_tokens,
temperature=0.7,
)
print(completion.choices[0].message)