How to Add Real-Time News to GPT-4 Agents (2025 Guide)
Getting real-time news into GPT-4, Claude, or any OpenAI-compatible LLM used to mean building JSON function schemas by hand, scraping news sites, and maintaining brittle integrations. wpnews eliminates all of that with 69 pre-built tool schemas you can drop in with two lines of Python.
tools = requests.get("https://api.wpnews.pro/api/v1/openai-tools.json").json() — paste into any OpenAI chat.completions.create call. GPT-4 automatically picks the right tool when your user asks about news.
Why agents need real-time news
LLMs have a training cutoff. For anything happening after that date — new AI model releases, startup funding rounds, regulatory news, market moves — they either hallucinate or admit they don't know. The fix is retrieval-augmented generation (RAG) with live news.
But not all news APIs are built for LLMs. Most require you to:
- Write JSON function schemas manually (error-prone, maintenance burden)
- Parse and clean raw article HTML yourself
- Handle rate limits, caching, and error responses
- Build entity extraction and topic classification on top
wpnews does all of this for you and ships 67 ready-to-use OpenAI function schemas.
Setup: 2-line integration
First, get a free API key at wpnews.pro/api (no credit card, instant). Then:
import openai
import requests
# Load all 67 wpnews tool schemas — no manual JSON definition
tools = requests.get(
"https://api.wpnews.pro/api/v1/openai-tools.json"
).json()
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
tools=tools,
messages=[{"role": "user", "content": "What's the biggest AI story today?"}],
)
print(response.choices[0].message.content)
That's it. GPT-4 will automatically call get_news, search_news, get_radar, or any of the other 69 tools based on what the user asks.
Handling tool calls (full agentic loop)
When GPT-4 decides to call a wpnews tool, you need to execute the call and return the result. wpnews provides a URL-resolver endpoint to make this easy:
import openai, requests, json
API_KEY = "YOUR_WPNEWS_KEY"
HEADERS = {"X-API-Key": API_KEY}
API_BASE = "https://api.wpnews.pro"
tools = requests.get(f"{API_BASE}/api/v1/openai-tools.json").json()
client = openai.OpenAI()
messages = [{"role": "user", "content": "Summarize AI funding news this week"}]
while True:
response = client.chat.completions.create(
model="gpt-4o", tools=tools, messages=messages
)
msg = response.choices[0].message
if msg.tool_calls:
messages.append(msg)
for tc in msg.tool_calls:
# Resolve tool name to API URL
url_resp = requests.get(
f"{API_BASE}/api/v1/openai-tools/{tc.function.name}/url",
params=json.loads(tc.function.arguments),
headers=HEADERS,
).json()
# Fetch the actual news data
news = requests.get(url_resp["url"], headers=HEADERS).json()
messages.append({
"role": "tool",
"tool_call_id": tc.id,
"content": json.dumps(news),
})
else:
print(msg.content)
break
Key tools for AI agent use cases
get_news— latest articles filtered by topic, sentiment, and languagesearch_news— full-text BM25 search with date range filteringget_radar— AI ecosystem temperature: trending topics, sentiment, top entityget_adaptive_context— auto-selects how much context to load (50-400 tokens) based on news activityget_news_velocity— detect news bursts before loading heavy contextget_trending_entities— companies and people surging in coverage right nowget_entity_brief— one-sentence snapshot of any named entity for system prompt injectionget_watchlist_digest— monitor multiple entities/topics in a single call
Pattern: smart context loading
Instead of blindly loading news into every agent call, use get_news_velocity as a gate:
import requests
API_KEY = "YOUR_WPNEWS_KEY"
HEADERS = {"X-API-Key": API_KEY}
velocity = requests.get(
"https://api.wpnews.pro/api/v1/news-velocity",
headers=HEADERS
).json()
if velocity["is_burst"]:
# Breaking news — load full context (400 tokens)
ctx = requests.get(
"https://api.wpnews.pro/api/v1/adaptive-context?force_mode=surge",
headers=HEADERS
).json()
elif velocity["is_quiet"]:
# Slow news day — minimal context (50 tokens)
ctx = requests.get(
"https://api.wpnews.pro/api/v1/adaptive-context?force_mode=quiet",
headers=HEADERS
).json()
else:
# Normal — auto-budget
ctx = requests.get(
"https://api.wpnews.pro/api/v1/adaptive-context",
headers=HEADERS
).json()
system_prompt = f"Current AI news context: {ctx['context_text']}"
Pricing and limits
- Free: 1,000 requests/day — enough for most development and low-traffic production
- Pro ($19/mo): 10,000 req/day, webhooks, 50-item watchlist, Pro-only endpoints
Try the demo endpoint without any key: curl https://api.wpnews.pro/api/v1/demo
Ready to add live news to your agent?
Free tier: 1,000 req/day, 69 tools, no credit card.