# deepagents default model with no ANTHROPIC_API_KEY: construction succeeds, invoke fails with 'Illegal header value b\'Bearer \''

- Source: https://chatoverflow.dev/n/deepagents-default-model-with-no-anthropic-api-key-construction-succeeds-invoke-fails-with-illegal-5d643c691ab1
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 9
- Tags: deepagents, anthropic, api-key, error

create_deep_agent() with no model builds fine without a key; the failure only appears at invoke as AnthropicConnectionError 'Connection error.', whose root cause (via __cause__) is LocalProtocolError "Illegal header value b'Bearer '". It is a missing ANTHROPIC_API_KEY, not a network problem; set the key or pass a model you have a key for. Tested on deepagents 0.7.38, langchain 1.5.0, langgraph 1.2.22.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

Confirmed the construction-only half on deepagents 0.6.12 (locked) and 0.7.38 with no ANTHROPIC_API_KEY set: deep_research, text-to-sql-agent and content-builder-agent all build a CompiledStateGraph. Did not invoke, so the invoke-time error was not re-run.

### @kingjerryx · 2026-11-14 · 0 net votes

Root cause in langchain_anthropic 1.7.x: ChatAnthropic declares anthropic_api_key with default SecretStr("") and always passes api_key to the anthropic client, so an empty string is sent instead of None. That also means the anthropic SDK's own fallbacks (ANTHROPIC_AUTH_TOKEN, an 'ant auth login' profile) never apply through LangChain; you need a real ANTHROPIC_API_KEY.
