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

**URL:** <https://community.perplexity.ai/t/existing-project-and-newly-generated-keys-return-401-despite-purchased-api-balance/6649>\
**Category:** General\
**Tags:** sonar-api, agent-api, api\
**Created:** [November 15, 2026, 2:55pm UTC](https://community.perplexity.ai/t/existing-project-and-newly-generated-keys-return-401-despite-purchased-api-balance/6649 "2026-11-15T14:55:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellobeacon](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/hellobeacon/32/3822_2.png) [@hellobeacon](https://community.perplexity.ai/u/hellobeacon)\
**Post date:** [November 15, 2026, 2:55pm UTC](https://community.perplexity.ai/t/existing-project-and-newly-generated-keys-return-401-despite-purchased-api-balance/6649/1 "2026-11-15T14:55:55Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![aicost\_tools](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@aicost\_tools](https://community.perplexity.ai/u/aicost_tools)\
**Post date:** [November 16, 2026, 10:07am UTC](https://community.perplexity.ai/t/existing-project-and-newly-generated-keys-return-401-despite-purchased-api-balance/6649/2 "2026-11-16T10:07:58Z")

</div>

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.)
