IntelliJ IDEA

How to fix the IntelliJ IDEA plugin returning 401 or an invalid API key

A 401 means the request reached the AI Code With server but failed authentication. The issue is in ANTHROPIC_AUTH_TOKEN, its validity, or the account state — not in the plugin install.

Start with these checks

The request reached the server, but authentication failed.

  • The plugin shows 401, Unauthorized, or Invalid API Key after sending a message.
  • ANTHROPIC_AUTH_TOKEN is incomplete, has extra spaces, or is the wrong key
  • Check in a terminal that ANTHROPIC_AUTH_TOKEN is exported
401UnauthorizedInvalid API Key

01

Confirm the request reached the server

401 / Unauthorized means the request successfully reached the AI Code With endpoint and was rejected at authentication. Do not change the plugin; check ANTHROPIC_AUTH_TOKEN first.

02

Re-export and verify the API key

In the terminal environment that launches IDEA, re-export the full AI Code With API key. Avoid trailing newlines or spaces when copying.

  1. 1Check in a terminal that ANTHROPIC_AUTH_TOKEN is exported
  2. 2Re-export the full API key, with no extra spaces

03

Verify the key and account

Confirm the key is active and the account has balance on the AI Code With API key page. After restarting IDEA, send a short message — no more 401 means the credential chain works.

  1. 1Re-export the full API key, with no extra spaces
  2. 2Confirm the key is a valid AI Code With API key (see the API key page)

If it is still not fixed

Sources

Reconfigure

Return to the integration center and continue the setup steps.

Return to the related setup step