> ## Documentation Index
> Fetch the complete documentation index at: https://docs.searchcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Step 3: Generate Content

<Note>
  **Internal Service** — This is not an HTTP endpoint. It's called by the create-ai-article orchestrator.
</Note>

## Purpose

Uses Gemini to generate unique, SEO-optimized content for the AI article based on the scraped AI site content.

## Function Signature

```python theme={null}
async def generate_article_content(
    business_id: str,
    product_id: Optional[str],
    article_id: str,
    scrape_result: dict,
    existing_posts: list
) -> dict
```

## Returns

```python theme={null}
{
    "status": "success",
    "title": "Complete Guide to Payment Processing",
    "slug": "complete-guide-payment-processing",
    "content": "...",  # Markdown content
    "meta_description": "...",
    "keywords": ["payment", "processing", "guide"]
}
```

## Content Generation

The LLM is prompted to:

1. **Analyze** the scraped content to understand the business
2. **Identify** a topic not covered by existing posts
3. **Generate** comprehensive, helpful content
4. **Optimize** for AI search engines

## Deduplication

Existing post titles/slugs are passed to prevent generating duplicate content:

```python theme={null}
existing_posts = [
    {"title": "Payment Gateway Guide", "slug": "payment-gateway-guide"},
    {"title": "Security Best Practices", "slug": "security-best-practices"}
]
```

The LLM is instructed to create content on a DIFFERENT topic.

## Code Location

```
src/app/apis/cron/create_boosted_page/children/step_3_generate_content.py
```
