Titikey
HomeTips & TricksChatGPT / Claude / Gemini API Error Checklist for “Invalid API Key”

ChatGPT / Claude / Gemini API Error Checklist for “Invalid API Key”

2/2/2026
实用技巧

What’s most rage-inducing isn’t that the model can’t write—it’s that just as you’re about to get to work, the console throws API key invalid, 401, or network error. The thing I’ve stumbled over the most is this: the key is fine; the problem is the “surrounding configuration.” This checklist is organized in the order I most often use: ChatGPT, Claude, then Gemini.

First, make sure you’re using the right key and the right project

A lot of people copy an old key, a test key, or switch projects in the console without noticing. I suggest you create a new key directly in the provider’s dashboard and replace it immediately—don’t get stuck wrestling with the old environment.

No permissions or billing enabled = effectively no key

A 401/403 doesn’t necessarily mean the key is wrong. Common causes are billing not enabled, insufficient permission scope, or organization/project restrictions. This is especially common with Claude and Gemini: it “looks like it should work,” but the moment you hit the API it errors out—don’t ask me how I know.

Environment variables and whitespace are silent killers

An extra space in your .env file, an unhandled newline, or a deployment platform failing to inject variables can all turn into an “invalid key.” Printing the key length and trimming leading/trailing whitespace is more useful than staring at the error for half an hour.

Network issues happen more often than you think

If you’re seeing timeouts, DNS failures, or intermittent 502s, suspect your network/proxy chain first. Some plugin docs even call out “network connectivity troubleshooting” as its own section—it’s really not being dramatic.

Don’t overlook fake errors caused by dependencies and versions

In Node projects, when you hit dependency issues like ETARGET, ERESOLVE, or ENOTEMPTY, the app may not even be running, yet you think the API is down. Stabilize your dependencies first, then test the endpoint.

My usual quick self-check order

  • Generate a new key and test immediately
  • Confirm project/org/permission settings and billing status
  • Check whether environment variables are injected and whether there are spaces/newlines
  • Retest on a direct connection or a cleaner proxy
  • Rule out dependency installation and runtime errors

If you also want to connect Claude to more tools (for example, using MCP to quickly “plug” an existing API into an assistant), I recommend smoothing out these three things first: account, key, and network. If you want to save time and avoid pitfalls, check out Titikey for the tool list and hands-on notes I compiled—mostly the “you can copy-paste directly” kind.

HomeShopOrders