Why weekly digest bots quietly get expensive
The prototype is cheap. You point a script at three feeds, ask a model for a paragraph, and ship it. Six weeks later you're at sixty feeds, half of them paste full article bodies into the RSS payload, and your cron job re-summarizes the same URL every Monday because nothing remembers it already did that. The bill grows for reasons that have nothing to do with model quality.
Almost every runaway digest bot leaks money in the same four places:
Re-summarizing unchanged items — feeds change once per post, so the entry ID is a perfect cache key and you're ignoring it
Sending the entire article when the feed excerpt already contains the argument
Using the stronger model for per-item blurbs, where it adds nothing but latency and cost
Packing the whole week into a single prompt, so the same context gets billed over and over inside one long conversation
None of these are model problems. They're pipeline problems, and they're fixable with a few dozen lines of state management.
Tier the work, not just the model
A weekly digest has two very different jobs: many small, boring extraction calls, and exactly one judgement call that sets the tone of the issue. Route them to different tiers and the economics change completely.
| Pipeline stage | Model | Why this tier |
|---|---|---|
| Per-item blurb (dozens to hundreds of calls) | deepseek-v4-flash | Short extraction over truncated text — the fast default handles it without reasoning overhead |
| Topic tag and importance score | deepseek-v4-flash | Classification in JSON mode at temperature 0; no deep reasoning needed |
| Cross-item intro (one call per issue) | deepseek-v4-pro | Needs judgement across the whole week — the one place the stronger model earns its keep |
| An item already in the database | No call at all | Hash the entry ID, reuse the stored blurb |
Pricing is qualitative but predictable: flash is the cheaper tier and pro costs more per token, cache hits cost less than fresh reads, and off-peak requests cost less than peak. Check aicreditsapi.com/deepseek-prices for the current numbers before you size a budget — the shape of the curve matters more than any single rate.
A working weekly digest pipeline
Install the two dependencies, export your key, and run it: pip install openai feedparser, then export AICREDITS_API_KEY=... and python digest.py. It writes digest.md and is safe to run twice — the SQLite table is the memory that stops duplicate work.
# pip install openai feedparser
import hashlib
import os
import re
import sqlite3
from datetime import datetime, timedelta, timezone
import feedparser
from openai import OpenAI
client = OpenAI(
api_key=os.environ['AICREDITS_API_KEY'],
base_url='https://api.aicreditsapi.com/v1',
)
FLASH = 'deepseek-v4-flash'
PRO = 'deepseek-v4-pro'
FEEDS = {
'https://blog.python.org/feeds/posts/default': 'Python',
'https://simonwillison.net/atom/everything/': 'AI engineering',
'https://hnrss.org/frontpage': 'Hacker News',
}
DB = 'digest.db'
CHAR_BUDGET = 1500 # how many characters of article text we pay for
def connect():
conn = sqlite3.connect(DB)
conn.execute(
'CREATE TABLE IF NOT EXISTS seen ('
'id TEXT PRIMARY KEY, source TEXT, title TEXT, summary TEXT, ts TEXT)'
)
return conn
def clean(html, limit=CHAR_BUDGET):
text = re.sub(r'<[^>]+>', ' ', html or '')
text = re.sub(r'\s+', ' ', text).strip()
return text[:limit]
def entry_id(entry):
raw = entry.get('id') or entry.get('link') or entry.get('title', '')
return hashlib.sha256(raw.encode('utf-8')).hexdigest()[:16]
def summarize(title, text, source):
resp = client.chat.completions.create(
model=FLASH,
messages=[
{
'role': 'system',
'content': (
'You write blurbs for an engineering digest. One sentence, '
'under 30 words, no hype, no markdown, no meta-commentary.'
),
},
{
'role': 'user',
'content': f'Source: {source}\nTitle: {title}\n\n{text}',
},
],
max_tokens=80,
temperature=0.2,
)
return resp.choices[0].message.content.strip()
def collect(conn, days=7):
cutoff = datetime.now(timezone.utc) - timedelta(days=days)
added = 0
for url, source in FEEDS.items():
try:
feed = feedparser.parse(url)
except Exception as exc: # one dead feed must not kill the run
print('feed failed:', url, exc)
continue
for entry in feed.entries[:15]:
eid = entry_id(entry)
if conn.execute('SELECT 1 FROM seen WHERE id = ?', (eid,)).fetchone():
continue
stamp = entry.get('published_parsed') or entry.get('updated_parsed')
if stamp:
published = datetime(*stamp[:6], tzinfo=timezone.utc)
if published < cutoff:
continue
title = re.sub(r'\s+', ' ', entry.get('title', 'Untitled')).strip()
body = entry.get('summary', '')
if entry.get('content'):
body += ' ' + entry['content'][0].get('value', '')
blurb = summarize(title, clean(body), source)
conn.execute(
'INSERT INTO seen (id, source, title, summary, ts) VALUES (?, ?, ?, ?, ?)',
(eid, source, title, blurb, datetime.now(timezone.utc).isoformat()),
)
added += 1
conn.commit()
return added
def build_digest(conn, days=7):
cutoff = (datetime.now(timezone.utc) - timedelta(days=days)).isoformat()
rows = conn.execute(
'SELECT source, title, summary FROM seen WHERE ts >= ? ORDER BY source, ts DESC',
(cutoff,),
).fetchall()
if not rows:
return '# Weekly digest\n\nNo new items this week.\n'
grouped = {}
for source, title, summary in rows:
grouped.setdefault(source, []).append(f'- **{title}** — {summary}')
packed = '\n\n'.join(
f'{src}\n' + '\n'.join(items) for src, items in grouped.items()
)
resp = client.chat.completions.create(
model=PRO,
messages=[
{
'role': 'system',
'content': (
'You are the editor of a weekly engineering digest. Write '
'120-160 words of plain prose about what mattered this week '
'and why a working developer should care. No bullets, no '
'headings, no hype, no invented facts.'
),
},
{'role': 'user', 'content': packed},
],
max_tokens=400,
temperature=0.4,
)
lines = [
f'# Weekly digest — {datetime.now(timezone.utc):%Y-%m-%d}',
'',
resp.choices[0].message.content.strip(),
'',
]
for source, items in grouped.items():
lines.append(f'## {source}')
lines.extend(items)
lines.append('')
return '\n'.join(lines)
if __name__ == '__main__':
conn = connect()
print('new items:', collect(conn))
digest = build_digest(conn)
with open('digest.md', 'w', encoding='utf-8') as f:
f.write(digest)
print(digest)
Three details carry most of the savings. First, CHAR_BUDGET truncates every item before it reaches the API — RSS excerpts are usually enough to write a one-sentence blurb, so you almost never need the full article. Second, entry_id hashes the feed's own identifier (falling back to link, then title), which makes re-runs idempotent: run the script daily and it costs nothing on quiet days. Third, the expensive tier appears exactly once, at the end, over compressed blurbs rather than raw articles.
Add structured tags when you want sections
Once you have more than a dozen items, a flat list stops being readable. JSON mode on the fast tier gives you topic buckets and a rough importance score you can sort by — cheap, deterministic, and easy to validate.
import json
TAG_PROMPT = (
'Classify this feed item. Reply with JSON only, keys: '
'topic (one of ai, python, infra, security, product, other), '
'importance (integer 1-5), blurb (one sentence, under 25 words).'
)
def tag(title, text):
resp = client.chat.completions.create(
model='deepseek-v4-flash',
response_format={'type': 'json_object'},
messages=[
{'role': 'system', 'content': TAG_PROMPT},
{'role': 'user', 'content': f'{title}\n\n{text[:1200]}'},
],
max_tokens=120,
temperature=0,
)
data = json.loads(resp.choices[0].message.content)
return data['topic'], int(data['importance']), data['blurb']
Wrap the json.loads in a try/except and fall back to the plain blurb path when a key is missing. A digest that ships with one slightly generic line beats a cron job that crashes at 6 a.m.
Prompt rules that keep summaries honest
Ban meta-commentary. Telling the model to avoid phrases like "this article discusses" forces it to state the actual claim.
Cap length in words, not tokens. Word limits produce more consistent output and are easier to enforce in review.
Pass the source name in the user message so the model doesn't waste a sentence explaining what Hacker News is.
Ask for "why a developer should care" only in the synthesis step. Per-item calls should describe, not editorialize.
Never let the model supply numbers the excerpt doesn't contain — the fastest way to ship a wrong digest is a confident invented statistic.
The cheapest token in a digest pipeline is the one you never send — cache first, truncate second, and only then reach for a bigger model.
Scheduling, delivery, and the boring reliability bits
Run the collector daily and the digest builder weekly — separate cron entries, same database. On GitHub Actions, commit digest.db between runs (or store it in an artifact) so the dedupe memory survives; without it, every run reprocesses the visible window of each feed. Write digest.md into the repo for a free archive, then push it out via SMTP, a Telegram bot, or your newsletter provider's API.
Keep the per-feed try/except. Feeds rot constantly — moved domains, expired TLS certificates, malformed dates — and a single bad URL should never take down the whole issue.
Running this from outside China
The code above uses the OpenAI SDK against https://api.aicreditsapi.com/v1, so it stays portable: swap the base URL and key and nothing else changes. AiCredits sells DeepSeek API credits to international developers with ordinary payment methods — card or PayPal, no Chinese phone number or bank account required, which is the usual blocker for teams that just want to pay and ship. If you also want static checks on the pipeline code itself, the linting tools on the same site cover that. Current rates live at aicreditsapi.com/deepseek-prices.
FAQ
Cost scales with new items per week, not with feed count, so a few hundred low-volume feeds is fine once deduplication is in place. The real limits are wall-clock time and how readable the digest stays — past roughly thirty items per issue, add topic sections instead of adding more feeds.
Use the excerpt by default. Fetch the full page only when the excerpt is under a few hundred characters, and truncate before sending either way.
Treat it as undated: rely purely on the entry-ID check. You'll get the item once, which is the behavior you want.
Only for the cross-item introduction and any final editing pass. Per-item blurbs, tagging, and classification all run cleanly on the fast tier.