← Blog
5 min read

Build an Intelligence Agent in 5 Minutes

Go from zero to a working AI intelligence agent with the Polaris Python SDK. Start with a curl command, end with a full briefing function.

Step 0

Try It Right Now

Paste this into your terminal. No signup, no API key setup — the demo key works instantly.

bash
curl "https://api.thepolarisreport.com/api/v1/search?q=AI+regulation&api_key=demo"

You'll get back structured JSON with confidence scores, bias analysis, and counter-arguments on every result:

json
{
  "briefs": [
    {
      "headline": "EU AI Act enforcement begins...",
      "counter_argument": "Industry groups argue compliance costs...",
      "source_count": 4,
      "provenance": {
        "confidence_score": 0.92,
        "bias_score": 0.15
      },
      "sources": [
        { "name": "Reuters", "url": "..." },
        { "name": "Politico", "url": "..." }
      ]
    }
  ]
}

No signup required. The demo key gives you read-only access to the full API.

Step 1

Install the SDK

bash
pip install polaris-news

Step 2

Search for Intelligence

The search() method returns a SearchResponse with .briefs: List[Brief]. Each brief includes confidence, bias analysis, and sourcing.

python
from polaris_news import PolarisClient

client = PolarisClient(api_key="demo")

results = client.search(query="AI regulation", min_confidence=0.8, depth="standard")
for brief in results.briefs:
    print(f"[{brief.confidence:.0%}] {brief.headline}")
    print(f"  Bias: {brief.bias_score} | Sources: {brief.source_count}")
    print(f"  Counter: {brief.counter_argument[:80]}...")

Step 3

Track Trending Entities

trending_entities() returns a List[Entity] directly — not wrapped in a response object.

python
trending = client.trending_entities(limit=5)
for entity in trending:
    print(f"{entity.name} ({entity.type}) — {entity.mention_count} mentions")

Step 4

Compare Source Coverage

Pass a brief_id to see how different sources covered the same story. Each SourceAnalysis includes outlet, framing, political_lean, emphasis, and omissions.

python
comparison = client.compare_sources(brief_id=results.briefs[0].id)
for sa in comparison.source_analyses:
    print(f"{sa.outlet} ({sa.political_lean})")
    print(f"  {sa.framing[:100]}...")
print(f"\nSynthesis: {comparison.polaris_analysis.get('summary', '')}")

Step 5

Put It All Together

Here's a complete function that searches, analyzes sources, and tracks trending entities — a full news briefing in one call.

python
from polaris_news import PolarisClient

def news_briefing(topic: str) -> dict:
    client = PolarisClient()  # uses POLARIS_API_KEY env var

    # 1. Search for high-confidence briefs
    results = client.search(query=topic, min_confidence=0.8, depth="standard")
    top = results.briefs[0] if results.briefs else None
    if not top:
        return {"error": "No briefs found"}

    # 2. Compare source coverage on the top brief
    comparison = client.compare_sources(brief_id=top.id)

    # 3. Get trending entities
    trending = client.trending_entities(limit=5)

    return {
        "topic": topic,
        "top_brief": {
            "headline": top.headline,
            "confidence": top.confidence,
            "bias_score": top.bias_score,
            "counter_argument": top.counter_argument,
            "source_count": top.source_count,
        },
        "source_comparison": {
            "sources": [
                {"outlet": sa.outlet, "lean": sa.political_lean, "framing": sa.framing}
                for sa in comparison.source_analyses
            ],
            "synthesis": comparison.polaris_analysis.get("summary", ""),
        },
        "trending": [
            {"name": e.name, "type": e.type, "mentions": e.mention_count}
            for e in trending
        ],
    }

# Run it
briefing = news_briefing("AI regulation")
print(briefing)

What's Next