How to Add Real-Time News to GPT-4 Agents (2025 Guide)

2025-05-01 6 min read wpnews team

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.

TL;DR: 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:

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

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

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.

Get free API key → 5-min quickstart →
openai gpt-4 function-calling news-api ai-agents