llama_index
                                
                                 llama_index copied to clipboard
                                
                                    llama_index copied to clipboard
                            
                            
                            
                        Validation error for OpenAI when using GPTSimpleVectorIndex
I tried to use the example from the documentation, but I always get the openai key error when using GPTSimpleVectorIndex
import openai 
from gpt_index import SimpleDirectoryReader, GPTSimpleVectorIndex
openai.api_key = "YOUR KEY GOES HERE"
documents = SimpleDirectoryReader('data').load_data()
index = GPTSimpleVectorIndex('documents')
Any idea what's going wrong? It works fine with the key when I use only openai.
you need to explicitly add OPENAI_API_KEY environment variable. You can see the example here https://github.com/jerryjliu/gpt_index/blob/main/examples/paul_graham_essay/TestEssay.ipynb
Thanks, it worked now :)