perplexity.BadRequestError: Error code: 400 - {'error': {'message': 'Validation error: country must be provided as a valid 2-digit ISO country code, got MN', 'type': 'invalid_country_code', 'code': 400}}
Expected Behavior
When calling for information on Mongolia, ISO-Code 2 := “MN”. Same for Cameroon, “CM”, I expect to get searches for these countries but get nothing.
Actual Behavior
rejects MN, CM
Steps to Reproduce API Request & Response
Call the API with the following request:
completion = client.chat.completions.create(
*model*="sonar",
messages=[
{
“role”: “user”,
“content”: f"Retrieve important breaking news”
}
\],
country = “MN”,
)
perplexity.BadRequestError: Error code: 400 - {'error': {'message': 'Validation error: country must be provided as a valid 2-digit ISO country code, got MN', 'type': 'invalid_country_code', 'code': 400}}
Perplexity’s documentation states “For supported country codes, please refer to the list here”, but does not actually provide a complete list of supported countries. This creates confusion, as developers expect all valid ISO codes to work.
In fact, although the Perplexity API only accepts valid two-letter ISO 3166-1 alpha-2 codes, not all official ISO codes are currently supported. This is likely due to limitations in infrastructure, partner content providers, or a focus on larger and more frequently searched regions.
Perplexity recommends using accurate and complete geographic content, including country, region, city, and coordinate codes, to achieve maximum relevance and accuracy of results. Not all countries have equally well-integrated sources or data, which may be why some ISO codes do not work.
If it is important to work with a specific country, it is a good idea to report it as a bug so that it can be considered for future support expansion.