_ChemCrow / utils.py
doncamilom's picture
extra checks + new cc version
167e68e
raw
history blame
276 Bytes
from langchain.llms import OpenAI
def oai_key_isvalid(api_key):
"""Check if a given OpenAI key is valid"""
try:
llm = OpenAI(openai_api_key = api_key)
out = llm("This is a test")
print(out)
return True
except:
return False