Python CLI that writes a paragraph on any topic using the OpenAI API.
A small command-line tool that prompts the user for a topic, sends it to the OpenAI completions endpoint (gpt-3.5-turbo-instruct), and prints the generated paragraph. The point was not to ship a product — it was to practise integrating a third-party API end to end without any framework abstraction in the way.
The program is built around a single generateblog() function with a clean input loop. There is a deliberate minimalism here: no class hierarchy, no Click or Typer wrapper, no logging library. Just keyboard input, a single request call, and a print. Stripping the structure down to the essentials made the real concerns — environment configuration, request shaping, response parsing, error handling, and friendly UX — visible without any framework hiding them.
The API key is loaded from a .env file via python-dotenv so no secrets ever end up in source. Temperature is tuned to 0.5 for coherent but non-repetitive output; max_tokens is capped at 400 per paragraph because the goal is a paragraph, not an essay, and capped tokens are the cheapest way to enforce that. The input loop lets the user keep generating until they explicitly stop, with no rate-limit handling or session tracking — appropriate for a learning exercise, deliberately omitted for clarity.
The patterns that came out of this small project transferred directly to the AI coach inside Brutl Productivity, the much larger product later in this portfolio. The shape is the same — environment-managed credentials, single-purpose function, conservative parameter defaults, friendly retry UX. Building it small first made the larger build mostly a matter of swapping the prompt and the parameters.
Send a short brief — I'll reply within 24 hours with honest feedback and next steps.
Start a Project →