# User Location filter dont work

**URL:** <https://community.perplexity.ai/t/user-location-filter-dont-work/492>\
**Category:** General\
**Created:** [June 9, 2025, 4:57am UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492 "2025-06-09T04:57:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![udl](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/udl/32/246_2.png) [@udl](https://community.perplexity.ai/u/udl)\
**Post date:** [June 9, 2025, 4:57am UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/1 "2025-06-09T04:57:12Z")

</div>

I have a simple question for people used to Perplexity, this is what appears in the perplexity documentation:

> **[User Location Filter Guide - Perplexity](https://docs.perplexity.ai/guides/user-location-filter-guide#examples)**

```auto
import requests

url = "https://api.perplexity.ai/chat/completions"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
payload = {
    "model": "sonar-pro",
    "messages": [
        {"role": "system", "content": "You are a helpful local guide."},
        {"role": "user", "content": "What are some good coffee shops nearby?"}
    ],
    "web_search_options": {
      "user_location": {
        "latitude": 37.7749,
        "longitude": -122.4194
      }
    }
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())

```

but if a run that code this error appears:

{‘error’: {‘message’: “Validation error: For localization, latitude and longitude must be provided together alongside the ‘country’ parameter.”, ‘type’: ‘lat\_long\_without\_country’, ‘code’: 400}}

so.. what should I do? is this a bug?

---

<div class="post-metadata">

**Author:** ![vikvang](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@vikvang](https://community.perplexity.ai/u/vikvang)\
**Post date:** [June 9, 2025, 8:37pm UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/2 "2025-06-09T20:37:44Z")

</div>

Thanks for flagging this! I’m working on reproducing this issue right now.

---

<div class="post-metadata">

**Author:** ![vikvang](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@vikvang](https://community.perplexity.ai/u/vikvang)\
**Post date:** [June 9, 2025, 8:46pm UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/3 "2025-06-09T20:46:04Z")

</div>

> [@udl](#):
>
> ```auto
> {
> "model": "sonar-pro",
> "messages": [
> {"role": "system", "content": "You are a helpful local guide."},
> {"role": "user", "content": "What are some good coffee shops nearby?"}
> ],
> "web_search_options": {
> "user_location": {
> "country": "US",
> "latitude": 37.7749,
> "longitude": -122.4194
> }
> }
> }
> 
> ```

Looks like it is a bug! We’ll update the documentation accordingly. Adding the country code (shown above) will give a valid response. The latitude and longitude params are then used to filter locations within the specified country.

---

<div class="post-metadata">

**Author:** ![udl](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/udl/32/246_2.png) [@udl](https://community.perplexity.ai/u/udl)\
**Post date:** [June 9, 2025, 8:57pm UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/4 "2025-06-09T20:57:45Z")

</div>

So… there’s no way to search by location without the country code? In the case I’m working with, I only have the latitude and longitude.

---

<div class="post-metadata">

**Author:** ![vikvang](https://avatars.discourse-cdn.com/v4/letter/v/67e7ee/32.png) [@vikvang](https://community.perplexity.ai/u/vikvang)\
**Post date:** [June 9, 2025, 9:25pm UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/5 "2025-06-09T21:25:40Z")

</div>

Right now, no. The team is actively working on making this possible!

---

<div class="post-metadata">

**Author:** ![Pat](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/pat/32/208_2.png) [@Pat](https://community.perplexity.ai/u/Pat)\
**Post date:** [July 18, 2025, 7:24pm UTC](https://community.perplexity.ai/t/user-location-filter-dont-work/492/6 "2025-07-18T19:24:38Z")

</div>

Just noting that this issue is also affecting me.

Thanks!
