OpenAI + Benzinga News: How to Summarize Stock Headlines with GPT

Every stock generates headlines. Some days it’s one or two. Other times it’s a flood.

For most users, the problem isn’t a lack of information — it’s too much of it. A trader clicks into a stock page and sees 10 articles. A few might be relevant. Others are noise. But reading each one takes time, and scanning through titles doesn’t always offer clarity.

Expectations have shifted. Users now look for context, not content. They want to know: What’s the story today? Is the stock moving because of earnings? A new product? An analyst upgrade? Just give me the gist, clearly and quickly.

That’s why summarization is no longer a nice-to-have. It’s becoming a standard user expectation. Platforms that offer smart recaps don’t just feel cleaner but rather assistive. They remove friction, boost engagement, and help users get value without extra effort.

And with APIs like Benzinga’s Newsfeed and GPT models from OpenAI, this is now easier to build than ever.

Use Case: Give Users a 1-Paragraph Briefing Instead of 10 Links

The typical stock page experience still revolves around headlines. Users see a list of articles, maybe sorted by time or ticker. But in a market that moves fast, skimming through multiple titles doesn’t cut it.

The goal here is different: instead of surfacing 10 links, offer a 1-paragraph summary of what’s happening with a stock today. It’s the kind of feature that makes a product feel modern and user-aware.

This is especially useful for:

  • Dashboards: Auto-generate news briefs for each stock tile or card.
  • Morning Briefings: Summarize what happened overnight or pre-market for popular names.
  • Low-Friction Alerts: Push a digest-style summary via email, SMS, or app notification without flooding the user with multiple links.

The value lies in context. A short summary can explain why a stock is moving, what the main themes are, and whether the sentiment seems positive or negative, all without requiring the user to read a single article.

In the next section, we’ll walk through how this can be implemented using Benzinga’s Newsfeed API and OpenAI’s GPT models.

Step-by-Step Implementation

Now that the goal is clear — a compact, daily summary of news for any stock — let’s walk through how to build it. This implementation uses Benzinga’s Newsfeed API for data and OpenAI for language generation.

Step 1: Pull Latest Headlines for a Symbol Using Benzinga Newsfeed API

The first step is to query Benzinga’s Newsfeed API for today’s headlines tied to a specific stock symbol. In this example, we’re using NVDA.

# 1. Import Required Packages

import requests
import html 
from openai import OpenAI

# 2. Fetch News

symbol = "NVDA" 
api_key = "YOUR BENZINGA API KEY"

url = "https://api.benzinga.com/api/v2/news"

headers = {"accept": "application/json"}

params = {
    "tickers": symbol,
    "displayOutput": "full",
    "dateFrom": '2025-07-24',
    "token": api_key
}

response = requests.get(url, params=params, headers=headers).json()

headlines = []
for article in sorted(response, key=lambda x: x.get("created"), reverse=True)[-5:]:
    title = article.get("title", "").strip()
    teaser = article.get("teaser", "").strip()
    if title or body:
        headlines.append(f"{title}: {teaser}")
        
headlines

This pulls the 5 most recent articles for the selected ticker, formats their title and teaser, and prepares them for summarization. You can adjust the number of articles or change the stock symbol dynamically depending on user input or your product’s logic.

Here’s the output, which shows the 5 headlines along with the teaser:

Step 2: Format the Titles and Teasers into a Prompt

Once we have the latest headlines, the next step is to package them into a structured prompt that GPT can understand and respond to effectively.

We’ll clean the text for any HTML entities, then frame a clear instruction for sentiment classification. The goal is to get a concise, explainable market briefing in return.

cleaned_texts = [html.unescape(text) for text in headlines]

prompt = f"""
You are a sentiment analysis model for financial news.

Below is a set of news headlines related to NVIDIA. Read them carefully and return:

1. Overall Sentiment: Positive, Negative, or Neutral
2. A one-sentence explanation for why you chose that sentiment

News headlines:
{chr(10).join(['- ' + text for text in cleaned_texts])}
"""

This approach keeps things simple for the model while still delivering enough context to generate meaningful output. The prompt structure is critical here as it helps ensure the result is structured and relevant.

Step 3: Send to OpenAI and Receive the Summary

With the prompt structured and cleaned, the final step is to feed it to OpenAI’s language model and retrieve the sentiment summary.

We’re using the gpt-3.5-turbo model via the openai Python client. The API call is made using a straightforward system-user message setup, with a low temperature value to keep the responses consistent and objective.

client = OpenAI(api_key="YOUR OPENAI API KEY")

response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[
        {"role": "system", "content": "You are a financial sentiment analysis assistant."},
        {"role": "user", "content": prompt}
    ],
    temperature=0.3
)

summary = response.choices[0].message.content
print(summary)

And here’s a real example of the output generated:

The model not only flags the sentiment (in this case, Positive) but also provides a clear rationale for its decision. This kind of explanation builds user trust and adds interpretability, which is especially important in financial applications.

If there are no relevant headlines in the given timeframe, you can also configure the script to return a fallback message like “No significant headlines found today.” This keeps the user experience smooth and consistent.

Integration Ideas: Where This Fits in Real Products

This summary tool isn’t just a backend demo. It’s a plug-and-play feature for:

  • In-app news modules: Show daily sentiment next to each stock on a watchlist.
  • Morning email briefings: Auto-generate a digest of top holdings with sentiment context.
  • Real-time alerts: Flag sudden sentiment shifts on high-volume tickers.
  • Portfolio dashboards: Offer a one-glance view of how sentiment is evolving across positions.

It works best when users need to stay informed, without diving into a dozen headlines.

Why This Works

This approach works because it pairs two strengths: structured news delivery and natural language understanding.

Benzinga’s Newsfeed API offers high-frequency, real-time financial headlines enriched with metadata like tickers, tags, and timestamps. This makes it easy to extract timely, relevant content for specific stocks without needing to build a full news ingestion pipeline.

On the other side, OpenAI’s language models can interpret and synthesize unstructured text into a brief summary that aligns with how traders consume information: fast, contextual, and sentiment-aware.

There’s no need for training custom NLP models, building classification logic, or managing infrastructure. The entire flow is prompt-driven and fully adaptable. Change the format, the tone, or the output length by simply modifying the instruction.

For teams building dashboards, alerts, or briefing tools, this provides a modular, low-latency solution to convert raw news into actionable context, with minimal engineering overhead.

OTHER ARTICLES

See what's happening at Benzinga

As new accounts stabilize, the intermediate trader will come into the limelight.  Here are Benzinga’s 2022 Data Market Predictions: 1.) Advanced Analytics will take Priority

Read More

As we close out Q1 of the new year, our attention is caught by the fact that the industry has exploded with a record number

Read More

In a fast paced world, empower users to make quick and subconscious decisions with a distinctive and easily recognizable company logo. Whether you use an

Read More