#openAI API keys not being recognized, anywhere.
3 messages · Page 1 of 1 (latest)
Ask chatGPT (free) to write a python script to TRY use your openAI API keys. Maybe the error messages it returns in python will give you useful information. CopyPaste the error messages into ChatGPT to interpret situation.
import openai
Set your OpenAI API key
openai.api_key = 'YOUR_API_KEY'
Example API call
def test_openai_api():
try:
response = openai.Completion.create(
engine='davinci',
prompt='Hello, world!',
max_tokens=5
)
print("API call successful!")
print("Response:", response)
except Exception as e:
print("API call failed!")
print("Error message:", str(e))
Test the OpenAI API
test_openai_api()