DEV Community

Elowen
Elowen

Posted on

Build an AI-Powered SEO Content Brief Generator with Python and SERP API

Ever spent hours researching what to write for your next blog post? You manually check the top 10 results, analyze what's working, and figure out how to make something better. What if you could automate that entire process with a few lines of code?

Today, we're going to build an AI-powered SEO content brief generator that automatically pulls the top 10 search results for your keyword and uses GPT to create a complete content brief. It takes about 10 minutes, and we'll be using Python and TalorData's SERP API.

Why Automate This?

Creating a good content brief used to take me 30–60 minutes per keyword. I'd:

  • Open incognito mode and search Google
  • Manually copy/paste titles and summaries into a document
  • Read through everything to identify common themes
  • Outline a structure that could compete

That's a lot of repetitive work that a computer can do for us. With automation, you can generate a complete content brief in under 10 seconds and just focus on writing the actual content.

Why Use a SERP API Instead of Scraping?

I tried building my own scraper for this years ago, and it was a never-ending maintenance nightmare:

  • Google keeps changing their HTML structure, so my selectors would break every few months
  • I kept getting blocked and had to mess around with rotating proxies
  • CAPTCHAs would randomly stop everything
  • When Google loads content dynamically with JavaScript, I needed a whole headless browser

Using a SERP API means someone else handles all that for you. You just make one API call and get clean structured JSON back.

What makes a SERP API good for this? You want an API that returns clean, structured JSON with titles, snippets, and URLs. No parser maintenance, no proxy management.

I'm using TalorData for this project because:

  • 1,000 free requests on signup (no credit card required)
  • $0.90 per 1,000 successful requests — super affordable
  • Supports Google, Bing, Yandex, and Baidu through a single endpoint
  • Simple API that doesn't require a heavy SDK

Let's Code It!

Install dependencies:

pip install requests openai python-dotenv
Enter fullscreen mode Exit fullscreen mode

Create a .env file:

TALORDATA_TOKEN=your_talordata_token_here
OPENAI_API_KEY=your_openai_key_here
Enter fullscreen mode Exit fullscreen mode

Complete code:

import requests
import openai
import os
from dotenv import load_dotenv

load_dotenv()

TALORDATA_TOKEN = os.getenv("TALORDATA_TOKEN")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
openai.api_key = OPENAI_API_KEY


def get_top_results(keyword: str, engine: str = "google", limit: int = 10):
    """Fetch top N search results from SERP API"""
    url = "https://serpapi.talordata.net/serp/v1/request"
    headers = {
        "Authorization": f"Bearer {TALORDATA_TOKEN}",
        "Content-Type": "application/x-www-form-urlencoded"
    }
    data = {
        "engine": engine,
        "q": keyword,
        "json": "2",
        "num": limit
    }

    response = requests.post(url, headers=headers, data=data)
    response.raise_for_status()
    results = response.json()

    return [
        {
            "position": r["position"],
            "title": r["title"],
            "snippet": r.get("snippet", "")
        }
        for r in results.get("organic_results", [])[:limit]
    ]


def format_results_for_prompt(results):
    """Format search results into something the LLM can read"""
    output = "Current top 10 search results:\n\n"
    for i, result in enumerate(results, 1):
        output += f"#{i} - Title: {result['title']}\n"
        output += f"Summary: {result['snippet']}\n\n"
    return output


def generate_content_brief(keyword: str, results):
    """Generate content brief using GPT"""
    context = format_results_for_prompt(results)

    prompt = f"""
You are an SEO expert. I want to write an article targeting: "{keyword}"

Based on the current top 10 search results for this keyword, analyze:

1. COMMON THEMES: What topics and angles are the top results covering?
2. GAPS: What questions are NOT being answered well?
3. TITLE SUGGESTIONS: 5 compelling title ideas that can outperform current results
4. OUTLINE: A detailed article outline with H2s and H3s that covers everything better
5. KEYWORD OPPORTUNITIES: Related keywords and questions to target

Current top search results:
{context}

Generate a comprehensive content brief that would help me create content that ranks.
"""

    response = openai.ChatCompletion.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
        temperature=0.7
    )

    return response.choices[0].message.content


if __name__ == "__main__":
    keyword = "best SERP API for developers 2026"

    print(f"🔍 Fetching top results for: {keyword}")
    results = get_top_results(keyword)

    print(f"📊 Found {len(results)} results")
    print("Generating content brief...\n")

    brief = generate_content_brief(keyword, results)

    print("=" * 60)
    print(f"📝 CONTENT BRIEF: {keyword}")
    print("=" * 60)
    print(brief)
Enter fullscreen mode Exit fullscreen mode

You can also use curl to test the API directly:

curl -X POST 'https://serpapi.talordata.net/serp/v1/request' \
  -H 'Authorization: Bearer your_token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'engine=google' \
  -d 'q=best SERP API' \
  -d 'device=desktop' \
  -d 'num=10' \
  -d 'json=2'
Enter fullscreen mode Exit fullscreen mode

The API returns clean, structured JSON with organic_results containing position, title, link, and snippet for each result.

What About Cost?

TalorData offers 1,000 free requests on signup with no credit card required. That's enough for extensive development and testing.

Beyond the free tier, pricing starts at $0.90 per 1,000 successful requests and drops to $0.25/1K at higher volumes. Compare that to incumbents at ~$10/1K. For full pricing details, visit talordata.com.

Next Steps

Once you have the basic generator running, consider:

  1. Add competitor analysis: Include domain authority data for each result
  2. Question extraction: Pull "People Also Ask" questions from SERP
  3. SERP feature detection: Check if AI Overviews or featured snippets appear
  4. Batch processing: Generate briefs for multiple keywords at once

Final Thoughts

Building an SEO content brief generator used to require managing scrapers, proxies, and parser maintenance. In 2026, a SERP API handles all that infrastructure so you can focus on what matters: creating great content.

The code above is production-ready — you can run it today with a free TalorData API key and start generating briefs in seconds instead of hours.


Have you built any SEO automation tools? What other workflows would you automate with a SERP API? Drop a comment below!

Top comments (0)