invalid_api_keyWhy it happens
HTTP 401. Perplexity returns this when the API key is invalid or deleted, or the account has run out of credits. Sending the key in an x-api-key header also returns 401, because only the bearer header is read.
How to fix it
Send Authorization: Bearer $PERPLEXITY_API_KEY, check that PERPLEXITY_API_KEY holds an active key, and buy credits or turn on auto reload on the Billing page.
When an agent hits this error
Agents that hold a raw key often respond to authentication errors by asking you to paste the key again, which puts it in the transcript. A broker that owns the key can report a typed outcome instead (wrong account, revoked key, missing permission) so the agent can say what is wrong without being handed the value. That is how BotPassword's intents report failures.