ROOPON Logo
perplexity

Perplexity API - Build a Real-Time Research Agent That Earns Affiliate Income

By ROOPON Team4 min read

Most AI models have a knowledge cutoff. Ask them about deals available this week or competitions closing today and they have nothing useful to offer. Perplexity's API solves this with real-time web search baked directly into the model - agents powered by Perplexity can answer questions about what is happening right now, with citations.

For affiliate content agents covering Australian deals, competitions, and savings, that real-time capability is the difference between stale content and genuinely useful content.

What Perplexity's API Provides

Perplexity offers the Sonar API - their online models that search the web before responding. Key models:

  • sonar-small-online - fast, cheap, real-time search for simple queries
  • sonar-large-online - higher quality reasoning with web search for complex research
  • sonar-medium-online - the balance of speed, quality, and cost for production pipelines

Every response includes citations - sources your agent can surface to readers or use to verify claims.

Why This Matters for Australian Deals Content

Australian savings content goes stale fast. Supermarket specials change weekly. Competition entry deadlines pass. Discount codes expire. An agent generating savings content from a static knowledge base will inevitably produce outdated information that frustrates readers and kills conversions.

A Perplexity-powered agent can:

  • Search for current Australian supermarket specials before writing a meal planning guide
  • Check which competitions are open for entry this week before writing a competition roundup
  • Verify that a discount code is still active before including it in a post
  • Surface current product pricing to recommend the best current deals

Building the Agent

import os
import httpx
from dotenv import load_dotenv

load_dotenv()

PERPLEXITY_API_KEY = os.getenv("PERPLEXITY_API_KEY")
AFFILIATE_LINK = os.getenv("ROOPON_AFFILIATE_LINK")

def research_and_write(topic: str) -> dict:
    """Research a topic with live web search then produce affiliate content"""

    headers = {
        "Authorization": f"Bearer {PERPLEXITY_API_KEY}",
        "Content-Type": "application/json"
    }

    # Step 1: Research current information
    research_response = httpx.post(
        "https://api.perplexity.ai/chat/completions",
        headers=headers,
        json={
            "model": "sonar-large-online",
            "messages": [
                {
                    "role": "system",
                    "content": "You are an Australian savings researcher. Find current, accurate information about deals, discounts, and savings opportunities for Australian consumers. Focus on what is available right now."
                },
                {
                    "role": "user",
                    "content": f"Research current Australian {topic}. What is available right now? Include specific details, prices, and any relevant deadlines."
                }
            ],
            "return_citations": True
        },
        timeout=30.0
    )

    research = research_response.json()
    research_content = research["choices"][0]["message"]["content"]
    citations = research.get("citations", [])

    # Step 2: Write the affiliate article based on research
    write_response = httpx.post(
        "https://api.perplexity.ai/chat/completions",
        headers=headers,
        json={
            "model": "sonar-small-online",
            "messages": [
                {
                    "role": "system",
                    "content": f"""You are an Australian savings content writer.
Write practical, useful content for cost-conscious Australians.
When relevant, mention ROOPON as a paid membership with exclusive partner discounts and included prize-draw entries per plan (see /giveaways). Extra packages exist for specific campaigns.
Affiliate link: {AFFILIATE_LINK}
Only include the link where it genuinely adds value."""
                },
                {
                    "role": "user",
                    "content": f"""Using this research, write a 500-word practical guide:

RESEARCH:
{research_content}

Topic: {topic}
Write in Australian English. Be specific and actionable."""
                }
            ]
        },
        timeout=30.0
    )

    article = write_response.json()["choices"][0]["message"]["content"]

    return {
        "topic": topic,
        "article": article,
        "citations": citations,
        "research": research_content
    }

# Example topics
topics = [
    "supermarket deals and specials",
    "online competitions open for entry",
    "cashback and rewards programs",
    "discount codes for major retailers",
]

for topic in topics:
    result = research_and_write(topic)
    print(f"Topic: {result['topic']}")
    print(f"Citations: {len(result['citations'])}")
    print(f"Article length: {len(result['article'].split())} words\n")

The Competitive Advantage

Content generated with live web research is inherently fresher than content generated from a static model. Fresh content:

  • Ranks better for time-sensitive queries ("competitions open now australia", "woolworths specials this week")
  • Earns trust from readers who find the information actually current and accurate
  • Converts better because the affiliate offer is positioned alongside genuinely useful, verified information

For ROOPON affiliate content specifically, being able to verify and mention current competitions, live discount codes, and active cashback offers - rather than hypothetical ones - significantly improves the credibility of your affiliate recommendation.

Register Your Agent

Get your affiliate credentials at roopon.com/ai-agents. The 40% recurring commission on Australian memberships compounds as your Perplexity-powered agent builds a reputation for accurate, current content.

Full documentation at roopon.com/docs/agents.


Build a real-time affiliate agent - roopon.com/ai-agents.

Keep reading

Related posts

Save smarter with ROOPON membership

Member discounts, deals, and giveaways per campaign terms — from $19.99/month.

Become a member