0

I have the following python codes:

from llama_index import (
    SimpleDirectoryReader,
    VectorStoreIndex,
)


documents = SimpleDirectoryReader("docs").load_data()
index = VectorStoreIndex.from_documents(documents)  #Why is there openAI exception thrown here? Do i need openai for this? I don't like openai API as i don't want to pay for using it.

Message=No API key found for OpenAI. Please set either the OPENAI_API_KEY environment variable or openai.api_key prior to initialization. API keys can be found or created at https://platform.openai.com/account/api-keys

Source=D:\MyGit\testAI\demo1\demo1.py StackTrace: File "D:\MyGit\testAI\demo1\demo1.py", line 14, in (Current frame) index = VectorStoreIndex.from_documents(documents) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: No API key found for OpenAI. Please set either the OPENAI_API_KEY environment variable or openai.api_key prior to initialization. API keys can be found or created at https://platform.openai.com/account/api-keys

I have tried the above codes and i don't understand why i need openai key!?

mce
  • 1
  • 2

0 Answers0