Skip to main content

HTTP 401 Unauthorized

Authentication is missing or invalid for this request.

4xx · Client error✗ not retryable — fix the request instead

In AI APIs specifically

Anthropic expects the x-api-key header; OpenAI expects Authorization: Bearer. Mixing the two conventions is the classic cause. Revoked or rotated keys also land here.

Fix checklist

  • Verify the correct auth header for the provider.
  • Check the key is set in the environment the process actually reads.
  • Confirm the key wasn't rotated or revoked in the console.
  • Watch for whitespace/newlines accidentally included in the key.

Spec: RFC reference