DEV Community

Build an AI Changelog Generator in Python

Writing changelogs is one of those developer tasks that sounds simple until you are staring at a messy commit history. Some commits matter to users. Some are internal cleanup. Some are merge commits. Some are meaningful only if you already know the codebase.

I built a small Python example that turns commit messages or git diffs into structured changelog JSON using Telnyx AI Inference.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/changelog-generator-python

What it does

The Flask app exposes:

  • POST /generate
  • POST /generate/from-diff
  • GET /changelogs
  • GET /changelogs/<id>
  • GET /health

POST /generate accepts a list of commit messages:

{
  "version": "v1.4.0",
  "repo_name": "billing-service",
  "commits": [
    "feat: add Stripe webhook retry with exponential backoff",
    "fix: correct tax calculation for EU VAT exemption",
    "docs: update API reference for invoice endpoint"
  ]
}

The app asks Telnyx AI Inference to return grouped changelog JSON with sections like:

  • Features
  • Bug Fixes
  • Improvements
  • Breaking Changes
  • Documentation
  • Other

There is also a POST /generate/from-diff endpoint if you want to summarize a git diff instead of commit messages.

Why structured output matters

For a changelog tool, plain text is useful, but structured output is more flexible. If the response comes back as JSON, you can:

  • render it in a docs site
  • save it in a release database
  • post it into a PR comment
  • send it to Slack
  • open a release-note review workflow
  • let a human approve it before publishing

The example stores generated changelogs in memory and gives each one an ID, so you can list recent changelogs or retrieve a specific one.

Run it

Clone the examples repo:

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/changelog-generator-python

Create your .env file:

cp .env.example .env

Add your Telnyx API key:

TELNYX_API_KEY=your_telnyx_api_key
AI_MODEL=moonshotai/Kimi-K2.6
HOST=127.0.0.1

Install and run:

pip install -r requirements.txt
python app.py

Try it:

curl -X POST http://localhost:5000/generate \
  -H "Content-Type: application/json" \
  -d '{
    "version": "v1.4.0",
    "repo_name": "billing-service",
    "commits": [
      "feat: add Stripe webhook retry with exponential backoff",
      "fix: correct tax calculation for EU VAT exemption",
      "docs: update API reference for invoice endpoint"
    ]
  }' | python3 -m json.tool

Where this could go

This is a small example, but it is a pretty practical developer tooling pattern:

  • generate draft release notes from merged PRs
  • summarize changes between two tags
  • create changelog drafts during CI
  • generate per-SDK release notes
  • publish to docs after human approval

The Telnyx code examples repo is also agent-readable, so you can use this example as a starting point and ask a coding agent to add GitHub integration, tag comparison, a UI, or a docs publishing step.

Resources

Comments

No comments yet. Start the discussion.