AI Disruption

AI Disruption

Claude Code 401 at the Company Gateway Fixed by Two Variables

Claude Code 401 errors at the company gateway usually mean the wrong credential variable. Learn the two env vars and curl test that fix it fast.

Meng Li's avatar
Meng Li
Oct 16, 2026
∙ Paid
I Tried Claude Code apiKeyHelper (My API Keys Now Rotate Automatically) |  by Joe Njenga | Medium

Last week I helped a friend debug a problem: Claude Code on his machine asked him to log in the moment it started, and after he logged in, it returned a 401.

It took me five minutes to spot the issue. The project gateway address his company gave him was correct, but he had put the key in the wrong variable. A one-word difference, and he spent a whole night going in circles between 401s and “please log in.”

The short version: connecting to a gateway comes down to two environment variables. But behind those two variables is a pile of pitfalls you only learn about by stepping in them, especially if you use a relay service, a company-wide gateway, or a proxy.

I’ve put together the pitfalls from that night, plus the error-reference table from the official docs, into this article.

User's avatar

Continue reading this post for free, courtesy of Meng Li.

Or purchase a paid subscription.
© 2026 Meng Li · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture