AttributeError: module 'openai' has no attribute 'DefaultHttpxClient' when running LangGraph example in Chainlit backend #793

Closed
opened 2026-02-20 17:41:47 -05:00 by yindo · 2 comments
Owner

Originally created by @sh-js on GitHub (Jul 11, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

I encountered an error when trying to run the LangGraph example inside the Chainlit backend. Specifically, I cloned the Chainlit repository and added the LangGraph example code in backend/chainlit/hello.py.

However, when I ran the code, I got the following error:


from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module>
    from langchain_openai.chat_models.azure import AzureChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module>
    from langchain_openai.chat_models.base import BaseChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module>
    from langchain_openai.chat_models._client_utils import (
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module>
    class _SyncHttpxClientWrapper(openai.DefaultHttpxClient):
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'DefaultHttpxClient'

Error Message and Stack Trace (if applicable)

from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module>
    from langchain_openai.chat_models.azure import AzureChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module>
    from langchain_openai.chat_models.base import BaseChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module>
    from langchain_openai.chat_models._client_utils import (
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module>
    class _SyncHttpxClientWrapper(openai.DefaultHttpxClient):
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'DefaultHttpxClient'

Description

I encountered an error when trying to run the LangGraph example inside the Chainlit backend. Specifically, I cloned the Chainlit repository and added the LangGraph example code in backend/chainlit/hello.py.

However, when I ran the code, I got the following error:

from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module>
    from langchain_openai.chat_models.azure import AzureChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module>
    from langchain_openai.chat_models.base import BaseChatOpenAI
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module>
    from langchain_openai.chat_models._client_utils import (
  File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module>
    class _SyncHttpxClientWrapper(openai.DefaultHttpxClient):
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'DefaultHttpxClient'

Steps to Reproduce:
Clone the Chainlit repo.

Add the LangGraph example ( https://docs.chainlit.io/integrations/langchain#with-langgraph ) code to backend/chainlit/hello.py.

Run the backend.

Environment:
Python version: 3.12

Poetry-managed virtualenv

Latest versions of chainlit(2.6.0), langchain (0.3.26), langchain_openai (0.3.27), and openai (1.93.3)

System Info

Steps to Reproduce:
Clone the Chainlit repo.

Add the LangGraph example ( https://docs.chainlit.io/integrations/langchain#with-langgraph ) code to backend/chainlit/hello.py.

Run the backend.

Environment:
Python version: 3.12

Poetry-managed virtualenv

Latest versions of chainlit(2.6.0), langchain (0.3.26), langchain_openai (0.3.27), and openai (1.93.3)

Originally created by @sh-js on GitHub (Jul 11, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python I encountered an error when trying to run the LangGraph example inside the Chainlit backend. Specifically, I cloned the Chainlit repository and added the LangGraph example code in backend/chainlit/hello.py. However, when I ran the code, I got the following error: from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module> from langchain_openai.chat_models.azure import AzureChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module> from langchain_openai.chat_models.base import BaseChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module> from langchain_openai.chat_models._client_utils import ( File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module> class _SyncHttpxClientWrapper(openai.DefaultHttpxClient): ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'openai' has no attribute 'DefaultHttpxClient' ``` ### Error Message and Stack Trace (if applicable) ```shell from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module> from langchain_openai.chat_models.azure import AzureChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module> from langchain_openai.chat_models.base import BaseChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module> from langchain_openai.chat_models._client_utils import ( File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module> class _SyncHttpxClientWrapper(openai.DefaultHttpxClient): ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'openai' has no attribute 'DefaultHttpxClient' ``` ### Description I encountered an error when trying to run the LangGraph example inside the Chainlit backend. Specifically, I cloned the Chainlit repository and added the LangGraph example code in backend/chainlit/hello.py. However, when I ran the code, I got the following error: ``` from langchain_openai.chat_models import AzureChatOpenAI, ChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/__init__.py", line 1, in <module> from langchain_openai.chat_models.azure import AzureChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/azure.py", line 21, in <module> from langchain_openai.chat_models.base import BaseChatOpenAI File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 105, in <module> from langchain_openai.chat_models._client_utils import ( File "/home/chaimaa/.cache/pypoetry/virtualenvs/chatbot-backend-a0QcPf-j-py3.12/lib/python3.12/site-packages/langchain_openai/chat_models/_client_utils.py", line 17, in <module> class _SyncHttpxClientWrapper(openai.DefaultHttpxClient): ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'openai' has no attribute 'DefaultHttpxClient' ``` Steps to Reproduce: Clone the Chainlit repo. Add the LangGraph example ( https://docs.chainlit.io/integrations/langchain#with-langgraph ) code to backend/chainlit/hello.py. Run the backend. Environment: Python version: 3.12 Poetry-managed virtualenv Latest versions of chainlit(2.6.0), langchain (0.3.26), langchain_openai (0.3.27), and openai (1.93.3) ### System Info Steps to Reproduce: Clone the Chainlit repo. Add the LangGraph example ( https://docs.chainlit.io/integrations/langchain#with-langgraph ) code to backend/chainlit/hello.py. Run the backend. Environment: Python version: 3.12 Poetry-managed virtualenv Latest versions of chainlit(2.6.0), langchain (0.3.26), langchain_openai (0.3.27), and openai (1.93.3)
yindo added the bugpendingawaiting author revision labels 2026-02-20 17:41:47 -05:00
yindo closed this issue 2026-02-20 17:41:47 -05:00
Author
Owner

@keenborder786 commented on GitHub (Jul 11, 2025):

Update your openai package to latest version and try.

@keenborder786 commented on GitHub (Jul 11, 2025): Update your openai package to latest version and try.
Author
Owner

@sydney-runkle commented on GitHub (Jul 20, 2025):

Hmm not able to reproduce this. Going to close for now. If you're still experiencing this issue on all latest versions, could you please open an issue on the langchain repository? Thank you!

@sydney-runkle commented on GitHub (Jul 20, 2025): Hmm not able to reproduce this. Going to close for now. If you're still experiencing this issue on all latest versions, could you please open an issue on the `langchain` repository? Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#793