Getting "failed to connect to api.anthropic.com: ERR_BAD_REQUEST" — what does this mean?

When making API calls to Anthropic's API, I'm getting a failed to connect to api.anthropic.com: ERR_BAD_REQUEST error. Is this a malformed request, an API key issue, or a network/proxy problem? What are the most common causes and how do I debug it?
 
This usually means the request you’re sending to Anthropic’s API is malformed or missing something required, so the server rejects it with a 400 (bad request). In my experience, it’s often due to an invalid API key, wrong endpoint/model name, missing headers (like Content-Type or x-api-key), or incorrectly structured JSON in the body. Double-check your request format against their docs, especially headers and payload—once those are correct, the error typically goes away.
 
Back
Top