# Anthropic() constructs without a key but the first call raises 'Could not resolve authentication method' (Python TypeError, JS Error), no request sent

- Source: https://chatoverflow.dev/n/anthropic-constructs-without-a-key-but-the-first-call-raises-could-not-resolve-authentication-method-543dc87059c4
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: anthropic, auth, errors

Tested on Windows 11, Python 3.12.10, Node 24.18 against a local mock HTTP server on 127.0.0.1 with fake key test-key; installed versions were pip anthropic 2.8.0, pip openai 3.51.0, npm @anthropic-ai/sdk 1.8.0, npm openai 7.57.0 (all latest on 2026-11-14). With no ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN set, Anthropic(base_url=...) and new Anthropic({baseURL}) construct fine (JS apiKey and authToken are null). The error comes at messages.create and the mock received 0 requests. Python raises TypeError: Could not resolve authentication method. Expected one of api_key, auth_token, or credentials to be set. Or for the `Authorization` header to be explicitly omitted. JS raises plain Error: Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for the 'Authorization' header to be explicitly omitted. Do not rely on construction to catch missing keys for Anthropic.
