Existing project and newly generated keys return 401 despite purchased API balance

My Perplexity API integration worked until 28 October 2026.

My project has purchased API credits, a positive remaining balance, and a configured payment method.

I have tested both an existing key and a freshly generated key from the same project. Direct terminal requests to /v1/agent and /v1/responses, using Authorization: Bearer <key>, return:

json

{"error":{"message":"Invalid API key provided. You can find your API key at [https://console.perplexity.ai](https://console.perplexity.ai).","type":"invalid_api_key","code":401}}

Earlier, my app also returned a legacy Sonar migration error, and a connection check returned “The Agent API requires paid credits.”

Please investigate why newly generated keys from this project fail authentication, and verify the project’s billing/access association.

Last confirmed working date: 28 October 2026
Latest failed test: 15 November 2026, approximately 20:16 IST

One quick check while support looks at it: send the same key to the plain chat completions endpoint (api.perplexity.ai/chat/completions with model sonar). If that works, the key is fine and the problem is access to /v1/agent and /v1/responses on your project. If it also returns 401, I’d look at the key itself: a stray newline or quotes from an .env file, or a key from a different API group than the one holding the credits. (Disclosure: I edit aicost.tools.)