Após execução deste código,
import os
from openai import OpenAI
client = OpenAI(
# This is the default and can be omitted
api_key=os.environ.get("MInha api Key"),
)
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-3.5-turbo",
)
print(chat_completion)
me apresenta o erro abaixo:
Traceback (most recent call last): File "c:\Users\rodolfo.matos\ProjetoAI\integracao_api.py", line 4, in client = OpenAI( ^^^^^^^ File "c:\Users\rodolfo.matos\ProjetoAI.venv\Lib\site-packages\openai_client.py", line 93, in init raise OpenAIError( openai.OpenAIError: 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