Describe the Bug
HTTP 400 returnd on Completion API
when request is done with “web_search_options” “country” param set to : “PR”
(proper 2-digit code for Puerto Rico)
Expected Behavior
Expected to be supported as other 2-digit country codes (“US”, …) .
Actual Behavior
HTTP 400 error returned in response:
{"error":{"message":"Validation error: country must be provided as a valid 2-digit ISO country code, got PR","type":"invalid_country_code","code":400}}
Steps to Reproduce
- Call the API with the following request:
curl --request POST --url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <api-key.....>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"web_search_options": {"user_location": {"country": "PR"}},
"messages": [{"role": "user","content": "How many stars are there in our galaxy?"}]}'
- Observe the unexpected behavior.
API Request & Response (if applicable)
curl --request POST --url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <api-key.....>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"web_search_options": {"user_location": {"country": "PR"}},
"messages": [{"role": "user","content": "How many stars are there in our galaxy?"}]}'
Environment
- API: https://api.perplexity.ai/chat/completions
- model: sonar