Describe the Bug
When pass the country as “RS”, the api returns 400 error code.
{
"error": {
"message": "Validation error: country must be provided as a valid 2-digit ISO country code, got RS",
"type": "invalid_country_code",
"code": 400
}
}
But RS is indeed a valid ISO 3166-1 alpha-2 country code for Serbia.
Request to reproduce:
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer xxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"messages": [
{
"content": "masking puff gde kupiti",
"role": "user"
}
],
"max_tokens": 123,
"temperature": 0.2,
"top_p": 0.9,
"search_domain_filter": [
"<any>"
],
"return_images": false,
"return_related_questions": false,
"search_recency_filter": "<string>",
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 1,
"response_format": {},
"web_search_options": {
"search_context_size": "low",
"user_location": {
"country": "RS"
}
}
}'
## ✅ Expected Behavior
successful code 200.
## ❌ Actual Behavior
400 bad request
## 🔄 Steps to Reproduce
1. Call the API with the following request:
2. Observe the unexpected behavior.
## 📌 API Request & Response (if applicable)
## 🌍 Environment
- **API Version:** [e.g., sonar-3.1]
- **SDK (if applicable):** [e.g., Python SDK v0.5]
- **Operating System:** [e.g., MacOS, Linux, Windows]
## 📎 Logs or Screenshots (if applicable)
Add any logs or screenshots that can help debug the issue.
## 📝 Additional Context
Add any other context about the problem here.