Skip to main content
Internal Service β€” This is not an HTTP endpoint. It’s called by the competitor research service.

Purpose

Step 2 of competitor research: Uses Exa’s Answer API to find 5 competitors based on the website content.

Function Signature

async def fetch_competitors_from_exa(api_key: str, url: str, website_content: str) -> list

Parameters

ParameterTypeDescription
api_keystrExa API key
urlstrBusiness URL (to exclude from results)
website_contentstrContent from Step 1

Returns

[
    {
        "name": "Competitor A",
        "website": "https://competitor-a.com",
        "strengths": ["strength 1", "strength 2", "strength 3"],
        "favicon_url": "https://..."
    },
    # ... 5 total
]

Prompt Engineering

The prompt instructs Exa to:
  1. Find exactly 5 competitors
  2. NOT include the original business
  3. Return 3 unique strengths per competitor (10-20 chars each)
  4. Return valid JSON format

Parsing Pipeline

Code Location

src/website/competitor_research/service.py
# Lines 90-165: fetch_competitors_from_exa()