Reading the news today feels like a full-time job that you have to dedicate your time and effort to. Dozens of headlines, hundreds of words per article, and barely enough time to skim through them all. So, in this guide, we have built an AI News Summarizer that does the reading for you.
It pulls news data using the NewsData.io News API and then asks GPT to turn it into a short, digestible summary.
The Idea
The concept is simple:
NewsData API + OpenAI = AI Summary of News
- Fetch the latest news articles on a topic using NewsData.io
- Feed the headlines and descriptions to GPT
- Get back a clean, human-readable summary.
That’s it. No fancy infrastructure needed: just two API calls and a bit of Python.
What You’ll Need
- 1. A free API key from NewsData.io
- 2. An API key from OpenAI
- 3. Python installed on your system
- 4. The
requestsandopenailibraries
Before we begin
Install the dependencies:
pip install requests openai
Step 1: Create the Python File
Newsdata.io gives you a Simple REST endpoint where you can search news by keyword, language, category, or country. Here’s a function that fetches the latest articles for a given query.
Create a file called news_summary.py and paste this:
import requests
from openai import OpenAI
# Add your API keys here
NEWSDATA_API_KEY = "YOUR_NEWSDATA_API_KEY"
OPENAI_API_KEY = "YOUR_OPENAI_API_KEY"
client = OpenAI(api_key=OPENAI_API_KEY)
# Fetch the latest news
def get_news(query="technology", language="en"):
url = "https://newsdata.io/api/1/latest"
params = {
"apikey": NEWSDATA_API_KEY,
"q": query,
"language": language
}
response = requests.get(url, params=params)
response.raise_for_status()
data = response.json()
return data.get("results", [])
# Summarize the news with OpenAI
def summarize_articles(articles):
combined_text = ""
for article in articles[:5]:
title = article.get("title", "")
description = article.get("description", "") or ""
combined_text += (
f"Title: {title}\n"
f"Description: {description}\n\n"
)
prompt = f"""
Summarize these news articles into a short,
easy-to-read daily briefing with bullet points.
Note: Keep it neutral and factual. Do not add information
that is not included in the articles.
{combined_text}
"""
response = client.responses.create(
model="gpt-4o-mini",
instructions="You are a helpful news summarizer.",
input=prompt
)
return response.output_text
# Run the program
if __name__ == "__main__":
topic = "artificial intelligence"
news = get_news(topic)
if not news:
print("No articles found. Try a different topic.")
else:
summary = summarize_articles(news)
print(f"\n📰 AI News Summary: {topic}\n")
print(summary)
A few notes:
- We’ve limited this to the top 5 articles (
articles[:5]) to keep the prompt short and summary focused. You can do this if you want a longer briefing. -
gpt-4o-miniworks great here; it’s fast and inexpensive for summarization tasks, such as this. You can switch it with any chat-completion-capable model. - The system message nudges GPT to stay factual rather than adding opinions or embellishments.
Step 3: Add your API keys
Replace:
NEWSDATA_API_KEY = "YOUR_NEWSDATA_API_KEY"
OPENAI_API_KEY = "YOUR_OPENAI_API_KEY"
With your actual API keys.
Step 4: Run it
Open Command Prompt in the folder containing the file and run:
python news_summary.py
You should get something like:
📰 AI News Summary: artificial intelligence
• A major technology company announced a new AI product...
• Researchers published new findings related to AI...
• Governments are introducing new policies around artificial intelligence...
• Several companies are investing in AI infrastructure...
Run this, and within a couple of seconds you’ll have a clean, bullet-pointed summary of the latest news on whatever topic you chose, built entirely from live data.
Step 5: Change the topic
Want news about something else? Just change:
topic = "artificial intelligence"
For example:
topic = "cryptocurrency"
or:
topic = "electric vehicles"
or:
topic = "global markets"
One important note: if you're publishing this tutorial now, I would avoid saying that gpt-4o-mini is the "best" or "recommended" model. The code can use it as a simple example, but model availability and recommendations can change.
Taking it further
This basic guide is just the starting point. Here are a few ideas to extend it:
- Schedule it using a cron job or GitHub Actions to email yourself a daily digest every morning.
- Add categories. NewsData.io supports filtering by category (business, sports, politics, etc), so you could build separate summaries for each category.
- Build a web app, wrap this logic in a small Flask or FastAPI backend, and display the summary on a simple frontend.
- Multilingual support. Newsdata.io supports multiple languages, so you could fetch and summarize news from different regions.
- Sentiment tagging. Ask GPT to also tag each bullet point as positive, negative, or neutral.
Wrapping Up
Combining a solid news API such as NewsData.io with the reasoning ability of GPT is a great example of how a few lines of code can save real time. You’re not replacing journalism; you’re just cutting through the noise faster, so you know what deserves a deeper read.
The full script is under 50 lines, costs pennies to run, and can be adapted pretty much for any topic, industry, or personal use case you have in mind. Give it a try, and let AI do your morning news scan for you.

Top comments (0)