# Request with country code:"PR" fails in Chat Completions API

**URL:** <https://community.perplexity.ai/t/request-with-country-code-pr-fails-in-chat-completions-api/610>\
**Category:** Bug Reports\
**Tags:** sonar-api\
**Created:** [July 1, 2025, 10:19am UTC](https://community.perplexity.ai/t/request-with-country-code-pr-fails-in-chat-completions-api/610 "2025-07-01T10:19:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michal\_Horzela](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/michal_horzela/32/351_2.png) [@Michal\_Horzela](https://community.perplexity.ai/u/Michal_Horzela)\
**Post date:** [July 1, 2025, 10:19am UTC](https://community.perplexity.ai/t/request-with-country-code-pr-fails-in-chat-completions-api/610/1 "2025-07-01T10:19:59Z")

</div>

## 🐛 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:

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

1. Call the API with the following request:

```auto
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?"}]}'
     

```

1. Observe the unexpected behavior.

## 📌 API Request & Response (if applicable)

```auto
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](https://api.perplexity.ai/chat/completions)
- model: sonar

---

<div class="post-metadata">

**Author:** ![Michal\_Horzela](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/michal_horzela/32/351_2.png) [@Michal\_Horzela](https://community.perplexity.ai/u/Michal_Horzela)\
**Post date:** [July 1, 2025, 10:22am UTC](https://community.perplexity.ai/t/request-with-country-code-pr-fails-in-chat-completions-api/610/2 "2025-07-01T10:22:36Z")

</div>

It was supposed to be resolved – see similar bug:

> [@Invalid verification ISO 3166-1 alpha-2 country code for Serbia](https://community.perplexity.ai/t/invalid-verification-iso-3166-1-alpha-2-country-code-for-serbia/427/3):
>
> Your request is correct, this is indeed a bug here. We will be resolving this on our end ASAP.
