When you’re coding and it suddenly throws “Invalid API key” or “403 Forbidden,” it really makes you want to close the laptop and go for a walk. I’ve compiled a general checklist based on the pitfalls I’ve personally run into—works for the APIs of ChatGPT, Claude, and Gemini in most cases; and although Midjourney isn’t an API, it has similar “permission/connection” gotchas.
First, make sure it’s not the most common beginner mistake
Many errors aren’t because the platform is down, but because we missed a character while copy-pasting.
- Make sure you’re using an “API Key,” not your web login password or a session
- Check for extra spaces or newlines, especially at the end of the .env file
- Check whether you accidentally deleted/reset the key—old keys become invalid immediately
401 and 403 are usually permissions or billing issues
401 is more like “Who are you?”, while 403 is more like “I know you, but you can’t come in.”
- ChatGPT-related: check whether you selected the wrong organization/project, and whether the key is under the correct project
- Claude/Gemini: confirm the account region and compliance requirements, and whether the corresponding API is enabled in the console
- General: missing billing setup, exhausted quota, or risk controls can all trigger 403
Timeouts and network issues: don’t just keep smashing retry
Borrowing some plugin troubleshooting ideas—network connectivity issues are more common than you think: DNS, proxies, and corporate gateways can all interfere.
- Switch networks or disable a “half-baked proxy,” and test a direct connection with curl/POSTMAN
- Check whether the request domain is being blocked and whether the certificate time is correct
- Implement retries with exponential backoff—don’t send 10 requests per second and get yourself flagged by risk controls
Midjourney “errors” are more like Discord permission problems
If you can’t generate images, first check whether you’re in a channel where you have permission, whether the bot is online, and whether you typed the command correctly. Also, here’s a creative tip: don’t start your prompt with a long essay—keeping it simple is more reliable (the KISS approach really works).
If you don’t want to burn creative energy on hassles like “payment, region, and network,” and want a smoother way to use these AI tools, you can check out Titikey—less tinkering, more creating.