Ask a Question
Back to All

API Bug: content-type ignored on response to 401 Unauthorized

Low priority/urgency bug:

When I intentionally hit the API without auth, the correct 401 Authorization Required response is returned - however the response is formatted in HTML, not JSON as specified in the content-type & Accept headers.

Steps to reproduce (lines 3 & 4 seem to be ineffective):

curl --request POST \
  --url <https://api.perplexity.ai/chat/completions>  \
  --header "authorization: Bearer ${INTENTIONALLY_BLANK}" \
  --header 'Accept: application/json' \ 
  --header 'content-type: application/json' \
  --data '{"model": "llama-3-sonar-large-32k-online", "messages": [{"role": "user", "content": "noop"}], "return_citations": true, "stream": false}'

<head><title>401 Authorization Required</title></head>
<center><h1>401 Authorization Required</h1></center>

Expected Results:

"status": 401,
"response": "unauthorized"

or similar