// Framework Integrations
Drop Polaris into any AI stack
Copy-paste examples for every major framework. Search news, pull feeds, find similar coverage, explore story clusters, and query structured data — all with confidence scores and bias detection.
Install
$ pip install langchain-core langchain-openai requests
Full Example
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
import requests
BASE = "https://api.thepolarisreport.com/api/v1"
@tool
def search_news(query: str) -> str:
"""Search verified news intelligence from The Polaris Report.
Returns briefs with confidence scores, bias detection, and counter-arguments."""
res = requests.get(f"{BASE}/search", params={"q": query, "limit": 5, "min_confidence": 0.7})
briefs = res.json().get("briefs", [])
return "\n\n".join([
f"[{b.get('confidence', 0):.0%} confidence] {b['headline']}\n"
f"{b['summary']}\n"
f"Bias: {b.get('bias_score', 'N/A')} | Counter: {b.get('counter_argument', 'N/A')}"
for b in briefs
])
@tool
def news_feed(category: str) -> str:
"""Get latest briefs from a category. Options: markets, crypto, ai_ml, tech,
politics, defense, cybersecurity, climate, energy, biotech, space, sports."""
res = requests.get(f"{BASE}/agent-feed", params={"category": category, "limit": 5})
briefs = res.json().get("briefs", [])
return "\n\n".join([
f"[{b.get('confidence', 0):.0%}] {b['headline']}: {b['summary']}"
for b in briefs
])
@tool
def similar_briefs(brief_id: str) -> str:
"""Find briefs with similar content to a given brief ID."""
res = requests.get(f"{BASE}/similar/{brief_id}", params={"limit": 5})
briefs = res.json().get("briefs", [])
return "\n\n".join([
f"[{b.get('similarity', 0):.0%} similar] {b['headline']}"
for b in briefs
])
@tool
def story_clusters(period: str = "24h") -> str:
"""Get story clusters — briefs grouped by topic. Period: 12h, 24h, 48h, 7d."""
res = requests.get(f"{BASE}/clusters", params={"period": period, "limit": 10})
clusters = res.json().get("clusters", [])
return "\n\n".join([
f"[{c['brief_count']} briefs] {c['topic']} — {', '.join(c.get('categories', []))}"
for c in clusters
])
@tool
def search_data(entity: str, data_type: str = "") -> str:
"""Search structured data points (money, percentages, metrics) by entity."""
params = {"entity": entity, "limit": 10}
if data_type:
params["type"] = data_type
res = requests.get(f"{BASE}/data", params=params)
points = res.json().get("data", [])
return "\n\n".join([
f"{d['data_point']['value']} ({d['data_point']['type']}) — {d['data_point']['context']}"
for d in points
])
# Create agent
tools = [search_news, news_feed, similar_briefs, story_clusters, search_data]
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = ChatPromptTemplate.from_messages([
("system", "You are a news analyst with access to The Polaris Report intelligence feed."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
result = executor.invoke({"input": "What are the latest developments in AI regulation?"})
print(result["output"])Available Endpoints
GET /api/v1/searchFull-text search with confidence and bias filtersGET /api/v1/agent-feedLLM-optimized feed, filterable by category and tagsGET /api/v1/similar/:idFind briefs with similar content by semantic similarityGET /api/v1/clustersStory clusters grouped by overlapping topicsGET /api/v1/dataStructured data points — funding, revenue, metrics, datesGET /api/v1/streamReal-time SSE stream of published and trending briefsPOST /api/v1/generate/briefOn-demand intelligence brief generation (API key required)?include_full_text=trueAdd to /feed or /brief/:id to get raw source article content