# How do I set up the Perplexity action to work well?

**URL:** <https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976>\
**Category:** Questions\
**Created:** [February 5, 2025, 9:25am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976 "2025-02-05T09:25:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecaveo](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ecaveo/32/6396_2.png) [@ecaveo](https://community.pickaxe.co/u/ecaveo)\
**Post date:** [February 5, 2025, 9:25am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/1 "2025-02-05T09:25:36Z")

</div>

Hoping someone can help me here. I have a Pro Perplexity subscription - I generated an API key and connected it via the action in the action library…

When I search via perplexity on the desktop, I get a comprehensive and correct/factual answer, but when I ask my tool the same question, it comes back with ‘I can’t find the answer’… Am I missing something here?

I have a rule in my Pickaxe that if the knowledge base doesn’t provide an answer, then search with perplexity.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Ned.Malki](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ned.malki/32/5918_2.png) [@Ned.Malki](https://community.pickaxe.co/u/Ned.Malki)\
**Post date:** [February 5, 2025, 1:55pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/2 "2025-02-05T13:55:43Z")

</div>

@nathaniel check this out 👀

---

<div class="post-metadata">

**Author:** ![ecaveo](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ecaveo/32/6396_2.png) [@ecaveo](https://community.pickaxe.co/u/ecaveo)\
**Post date:** [February 6, 2025, 11:53am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/3 "2025-02-06T11:53:59Z")

</div>

Further testing of this and it still doesn’t pull through anything useful form perplexity. I’ve switched the action back to Google and this works fine!

My preference would be to get Perplexity working as on the desktop, it givers a higher quality result.

Is anyone else getting an issue with the Perplexity Action?

---

<div class="post-metadata">

**Author:** ![Ned.Malki](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ned.malki/32/5918_2.png) [@Ned.Malki](https://community.pickaxe.co/u/Ned.Malki)\
**Post date:** [February 6, 2025, 12:32pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/4 "2025-02-06T12:32:59Z")

</div>

Hi @ecaveo can you do a screen recording or take some screenshots of the issue with the Perplexity action? It will definitely help with diagnosing the issue.

---

<div class="post-metadata">

**Author:** ![ecaveo](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ecaveo/32/6396_2.png) [@ecaveo](https://community.pickaxe.co/u/ecaveo)\
**Post date:** [February 6, 2025, 12:59pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/5 "2025-02-06T12:59:13Z")

</div>

Hi @Ned.Malki I have PM’d Screenshots.

---

<div class="post-metadata">

**Author:** ![Ned.Malki](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ned.malki/32/5918_2.png) [@Ned.Malki](https://community.pickaxe.co/u/Ned.Malki)\
**Post date:** [February 8, 2025, 10:01am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/6 "2025-02-08T10:01:47Z")

</div>

Hey @ecaveo thanks for sharing. I forwarded it to the Dev team for diagnosis.

---

<div class="post-metadata">

**Author:** ![ecaveo](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ecaveo/32/6396_2.png) [@ecaveo](https://community.pickaxe.co/u/ecaveo)\
**Post date:** [February 15, 2025, 11:53am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/7 "2025-02-15T11:53:19Z")

</div>

Any update on this - its still not working for me.

---

<div class="post-metadata">

**Author:** ![ryano562](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ryano562/32/1527_2.png) [@ryano562](https://community.pickaxe.co/u/ryano562)\
**Post date:** [March 27, 2025, 6:00pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/9 "2025-03-27T18:00:27Z")

</div>

![Screenshot 2025-03-27 at 12.55.20 PM](https://canada1.discourse-cdn.com/flex004/uploads/pickaxeproject/original/2X/e/eeb9e734821eb71fb62b0d52d87d211e9f92f3a4.png)  
 ![Screenshot 2025-03-27 at 12.55.27 PM](https://canada1.discourse-cdn.com/flex004/uploads/pickaxeproject/original/2X/7/7a3cea44ea3e8956f4e3bb500eb66a465a0e94cb.png)

This happens for me too. We are trying to use Perplexity for the most recent searches, the pickaxe tries, then fails, then uses Google Search (and doesn’t return the most recent search results)

Note: I am using Sonar Pro

```auto
   perplexity_api_key = os.environ["PERPLEXITY_SONAR_API_KEY"]

    url = "https://api.perplexity.ai/chat/completions"

    payload = {
        "model": "sonar-pro",
        "messages": [
            {
                "role": "system",
                "content": "Be precise and concise."

```

---

<div class="post-metadata">

**Author:** ![ryano562](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/ryano562/32/1527_2.png) [@ryano562](https://community.pickaxe.co/u/ryano562)\
**Post date:** [March 27, 2025, 6:27pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/10 "2025-03-27T18:27:23Z")

</div>

This code works:

```auto
import os
import requests
import json

def answer_with_perplexity_copy(query: str):
    """
    If a user prompt requires a search, to verify facts, or include references, use Perplexity to retrieve the information and reference URLs.

    Args:
        query (string): The query for perplexity. It can be in natural language.
    Envs:
        PERPLEXITY_SONAR_API_KEY (string): API key from Perplexity
    """

    # Insert your PYTHON code below. You can access environment variables using os.environ[].
    # Currently, only the requests library is supported, but more libraries will be available soon.
    # Use print statements or return values to display results to the user.
    # If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
    # You do not have to call this function as the bot will automatically call and fill in the parameters.

    perplexity_api_key = os.environ["PERPLEXITY_SONAR_API_KEY"]
    if not perplexity_api_key:
        return "Error: API key is missing or empty. Please check your environment variables."
    
    url = "https://api.perplexity.ai/chat/completions"
    payload = {
        "model": "sonar-pro",
        "messages": [
            {
                "role": "system",
                "content": "Be precise and concise."
            },
            {
                "role": "user",
                "content": query
            }
        ],
        "temperature": 0.2,
        "top_p": 0.9,
        "search_domain_filter": [], # Removed limitation to just perplexity.ai
        "search": True, # Explicitly enable search
        "return_urls": True, # Make sure to return URLs
        "return_images": False,
        "return_related_questions": False,
        "search_recency_filter": "month",
        "top_k": 0,
        "stream": False,
        "presence_penalty": 0,
        "frequency_penalty": 1
    }
    
    headers = {
        "Authorization": f"Bearer {perplexity_api_key}",
        "Content-Type": "application/json"
    }
    
    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status() # Raise exception for 4XX/5XX responses
        
        data = response.json()
        
        # Format and return the result with sources
        if "choices" in data and data["choices"]:
            answer = data["choices"][0]["message"]["content"]
            
            # Extract and format sources if available
            sources = []
            if "urls" in data and data["urls"]:
                sources = [f"- {url}" for url in data["urls"]]
            
            result = answer
            if sources:
                result += "\n\nSources:\n" + "\n".join(sources)
            
            return result
        else:
            return "Error: Unexpected response format from Perplexity API."
            
    except requests.exceptions.RequestException as e:
        return f"Error connecting to Perplexity API: {str(e)}"
    except json.JSONDecodeError:
        return "Error: Could not parse the API response."
    except Exception as e:
        return f"Unexpected error: {str(e)}"

```

---

<div class="post-metadata">

**Author:** ![tonyyap](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tonyyap](https://community.pickaxe.co/u/tonyyap)\
**Post date:** [April 17, 2025, 7:14am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/11 "2025-04-17T07:14:53Z")

</div>

the existing perplexity action doest work. It doesnt return the latest info upon searching. When will this be fixed?

---

<div class="post-metadata">

**Author:** ![tonyyap](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tonyyap](https://community.pickaxe.co/u/tonyyap)\
**Post date:** [April 17, 2025, 7:39am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/12 "2025-04-17T07:39:48Z")

</div>

complicated for non-technical.Mind telling how to use?

---

<div class="post-metadata">

**Author:** ![stephenasuncion](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/stephenasuncion/32/3111_2.png) [@stephenasuncion](https://community.pickaxe.co/u/stephenasuncion)\
**Post date:** [September 25, 2025, 2:29am UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/13 "2025-09-25T02:29:59Z")

</div>

We’ve added 5 new models from Perplexity, if you guys want to use the model but Action is not supported:

 ![image](https://canada1.discourse-cdn.com/flex004/uploads/pickaxeproject/original/2X/4/471684dacb7324f8a25953157f634c43f0f8b199.png)

---

<div class="post-metadata">

**Author:** ![nathaniel](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.pickaxe.co/nathaniel/32/11_2.png) [@nathaniel](https://community.pickaxe.co/u/nathaniel)\
**Post date:** [November 18, 2025, 5:44pm UTC](https://community.pickaxe.co/t/how-do-i-set-up-the-perplexity-action-to-work-well/3976/14 "2025-11-18T17:44:18Z")

</div>

We should probably also make the perplexity action work again, in case people want to use it like that.
