OpenAIError in Customer-Support tutotial: The api_key client option must be set either by passing api_key #303

Closed
opened 2026-02-20 17:36:00 -05:00 by yindo · 4 comments
Owner

Originally created by @giusarno on GitHub (Nov 5, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

retriever = VectorStoreRetriever.from_docs(docs, openai.Client())

Error Message and Stack Trace (if applicable)

OpenAIError: The api_key client option must be set either by passing api_key

Description

I'm trying to run the customer-support.ipynb example and I hit an issue under Tools first IN @line 43 with the mentioned error message. I can see the tutorial sets API KEYs for Anthropic and not openai. I assume this is a bug ?

System Info

python -m langchain_core.sys_info

System Information

OS: Windows
OS Version: 10.0.22631
Python Version: 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)]

Package Information

langchain_core: 0.3.15
langchain: 0.3.7
langchain_community: 0.3.5
langsmith: 0.1.139
langchain_anthropic: 0.2.4
langchain_openai: 0.2.5
langchain_text_splitters: 0.3.2
langgraph: 0.2.45

Originally created by @giusarno on GitHub (Nov 5, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python retriever = VectorStoreRetriever.from_docs(docs, openai.Client()) ``` ### Error Message and Stack Trace (if applicable) ```shell OpenAIError: The api_key client option must be set either by passing api_key ``` ### Description I'm trying to run the **customer-support.ipynb** example and I hit an issue under **Tools** first IN @line 43 with the mentioned error message. I can see the tutorial sets API KEYs for Anthropic and not openai. I assume this is a bug ? ### System Info python -m langchain_core.sys_info System Information ------------------ > OS: Windows > OS Version: 10.0.22631 > Python Version: 3.13.0 (tags/v3.13.0:60403a5, Oct 7 2024, 09:38:07) [MSC v.1941 64 bit (AMD64)] Package Information ------------------- > langchain_core: 0.3.15 > langchain: 0.3.7 > langchain_community: 0.3.5 > langsmith: 0.1.139 > langchain_anthropic: 0.2.4 > langchain_openai: 0.2.5 > langchain_text_splitters: 0.3.2 > langgraph: 0.2.45
yindo closed this issue 2026-02-20 17:36:00 -05:00
Author
Owner

@vbarda commented on GitHub (Nov 5, 2024):

thanks for reporting -- we are indeed missing an input for OPENAI_API_KEY. but if you set it, the notebook runs for you, right?

@vbarda commented on GitHub (Nov 5, 2024): thanks for reporting -- we are indeed missing an input for `OPENAI_API_KEY`. but if you set it, the notebook runs for you, right?
Author
Owner

@giusarno commented on GitHub (Nov 5, 2024):

Yes I added

_set_env("OPENAI_API_KEY")
after

_set_env("ANTHROPIC_API_KEY")
_set_env("TAVILY_API_KEY")

also noticed the initial line has a minor issue

% pip install -U langgraph langchain-community langchain-anthropic tavily-python pandas
a space between % and pip.
I am not familiar with process whether I should simply create a pull request and fix or something else. In any case it worked thanks.

Not sure the best place for this question however what is the purpose of using the OpenAI LLM at this point in the code ?

@giusarno commented on GitHub (Nov 5, 2024): Yes I added `_set_env("OPENAI_API_KEY") ` after ``` _set_env("ANTHROPIC_API_KEY") _set_env("TAVILY_API_KEY") ``` also noticed the initial line has a minor issue `% pip install -U langgraph langchain-community langchain-anthropic tavily-python pandas ` a space between % and pip. I am not familiar with process whether I should simply create a pull request and fix or something else. In any case it worked thanks. Not sure the best place for this question however what is the purpose of using the OpenAI LLM at this point in the code ?
Author
Owner

@vbarda commented on GitHub (Nov 5, 2024):

Not sure the best place for this question however what is the purpose of using the OpenAI LLM at this point in the code ?

it's used for embeddings in the VectorStoreRetriever, not as an LLM

@vbarda commented on GitHub (Nov 5, 2024): > Not sure the best place for this question however what is the purpose of using the OpenAI LLM at this point in the code ? it's used for embeddings in the `VectorStoreRetriever`, not as an LLM
Author
Owner

@vbarda commented on GitHub (Nov 5, 2024):

Fixed here! https://github.com/langchain-ai/langgraph/pull/2350

@vbarda commented on GitHub (Nov 5, 2024): Fixed here! https://github.com/langchain-ai/langgraph/pull/2350
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#303