-
Notifications
You must be signed in to change notification settings - Fork 16.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting a custom http_client fails with unexpected keyword argument when use ChatAnthropic #30146
Comments
Hi @zhanghao-AI , are you working on this feature? |
I encountered this problem when I used langchain to call the claude-3-7-sonnet-20250219 model, and it has not been solved yet. Do you have any solution? |
No, but I will fix this issue as soon as possible. |
TypeError Traceback (most recent call last) File d:\soft\anaconda\envs\langchain\Lib\site-packages\langchain_core\load\serializable.py:125, in Serializable.init(self, *args, **kwargs)
File d:\soft\anaconda\envs\langchain\Lib\site-packages\langchain_openai\chat_models\base.py:527, in BaseChatOpenAI.validate_environment(self) File d:\soft\anaconda\envs\langchain\Lib\site-packages\openai_client.py:123, in OpenAI.init(self, api_key, organization, project, base_url, timeout, max_retries, default_headers, default_query, http_client, _strict_response_validation) File d:\soft\anaconda\envs\langchain\Lib\site-packages\openai_base_client.py:856, in SyncAPIClient.init(self, version, base_url, max_retries, timeout, transport, proxies, limits, http_client, custom_headers, custom_query, _strict_response_validation) File d:\soft\anaconda\envs\langchain\Lib\site-packages\openai_base_client.py:754, in _DefaultHttpxClient.init(self, **kwargs) TypeError: Client.init() got an unexpected keyword argument 'proxies' I also have the same problem, what the problem is? |
A dependencies issue arose with |
Checked other resources
Example Code
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(
thinking={
"type": "enabled",
"budget_tokens": 1024
},
model="claude-3-7-sonnet-20250219",
max_tokens=4096,
http_client=httpx.Client()
)
Error Message and Stack Trace (if applicable)
File "test_claude37_langchain.py", line 46, in
llm_result = llm.invoke(prompt_result)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\langchain_core\language_models\chat_models.py", line 285, in invoke
self.generate_prompt(
File "\Lib\site-packages\langchain_core\language_models\chat_models.py", line 861, in generate_prompt
return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\langchain_core\language_models\chat_models.py", line 691, in generate
self._generate_with_cache(
File "\Lib\site-packages\langchain_core\language_models\chat_models.py", line 926, in _generate_with_cache
result = self._generate(
^^^^^^^^^^^^^^^
File "\Lib\site-packages\langchain_anthropic\chat_models.py", line 948, in _generate
data = self._client.messages.create(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\anthropic_utils_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: Messages.create() got an unexpected keyword argument 'http_client'
Description
When I use ChatAnthropic, I want to customize http_client. I noticed that ChatOpenAI can do this. But when I use ChatAnthropic, it doesn't work. Does ChatAnthropic not handle this parameter? I can set it using the anthropic SDK. Do you plan to add this parameter in the next version?
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: