How is the Open.AI API Key passed?

Since we are not explicitly/ directly calling Open.AI classes when using LangChain, is it correct to say that the OpenAI API key is picked up from environment automatically when we call ChatOpenAI class? For example, in L2-Memory, OpenAI API is not called anywhere. Appreciate clarification.

Yes you can say that, there is probably some other file in that directory that contains the OPENAI API key.

1 Like

Thanks for the reply. In such a case, if I were to use my own OpenAI API key, how do I call that with LangChain? Appreciate inputs.

Have a look on this tutorial, you can find other similar by googling: