Search code examples
pythonasync-awaithttpxanthropic

TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'


Error:

File "/app/.venv/lib/python3.11/site-packages/anthropic/_client.py", line 386, in __init__   
super().__init__(   
File "/app/.venv/lib/python3.11/site-packages/anthropic/_base_client.py", line 1437, in __init__     
self._client = http_client or AsyncHttpxClientWrapper(^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.11/site-packages/anthropic/_base_client.py", line 1334, in __init__     
super().__init__(**kwargs)
TypeError: Async`Client.__init__() got an unexpected keyword argument 'proxies'

I know that to fix this problem i need to downgrade httpx to another version, but what if im using fasthx = "2.0.1". Whats the solution for Antropic AI?
My code:

load_dotenv()
log = logging.getLogger(__name__)


anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
anthropic_client = anthropic.Anthropic(api_key=anthropic_api_key)  # <-- Eror happens here
anthropic_client = instructor.from_anthropic(anthropic_client)

I want to fix the error TypeError: AsyncClient.init() got an unexpected keyword argument 'proxies'


Solution

  • Just upgrade anthropic to the latest version, the problem was fixed in version 0.45.2 and above.