DEV Community

hahamerry
hahamerry

Posted on

How I Built a Smart CLI Tool with DeepSeek API in One Afternoon

How I Built a Smart CLI Tool with DeepSeek API in One Afternoon

I recently needed a way to generate commit messages, summarize pull requests, and draft release notes — all from the terminal. Instead of stitching together multiple SaaS tools, I decided to wire up DeepSeek's API myself. Here's what I learned.

Why DeepSeek?

DeepSeek's API is dead simple. It follows the OpenAI-compatible chat completion format, so if you've ever used GPT's API, you already know how to call it. The pricing is also absurdly cheap — I processed over 2,000 requests during development and burned through less than $0.50.

The Setup (Under 10 Minutes)

import requests

API_KEY = "your-deepseek-key"
ENDPOINT = "https://api.deepseek.com/v1/chat/completions"

def ask_deepseek(prompt):
    resp = requests.post(ENDPOINT, headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    }, json={
        "model": "deepseek-chat",
        "messages": [{"role": "user", "content": prompt}],
        "temperature": 0.3
    })
    return resp.json()["choices"][0]["message"]["content"]
Enter fullscreen mode Exit fullscreen mode

That's it. Swap deepseek-chat for deepseek-reasoner if you need chain-of-thought reasoning for complex tasks.

Three Things That Surprised Me

  1. Speed: Responses came back faster than I expected — under 2 seconds for most prompts, including the reasoning model.

  2. JSON mode actually works: I needed structured output for changelog generation. DeepSeek's JSON mode returned valid, parseable JSON on the first try 90%+ of the time. A quick retry fallback handled the rest.

  3. Long context is real: The 128K context window meant I could dump entire PR diffs into the prompt without chunking. That alone saved hours of engineering time.

What I Built

In about four hours, I had a CLI tool that:

  • Generates conventional commit messages from staged diffs
  • Summarizes merged PRs into clean changelog entries
  • Drafts release notes with categorized changes

All running locally, no monthly subscription, no vendor lock-in.

The Takeaway

If you've been putting off integrating AI into your workflow because of cost or complexity, DeepSeek's API removes both barriers. Start with one small automation — a bash alias, a git hook, a Slack bot — and iterate from there.


Need help wiring up AI APIs or building custom automation? I offer affordable development services on Fiverr: Get a custom integration or Automate your workflows.

Top comments (0)