llm

Articles about large language models: how they work and how to use them from Python.

Python Chatbot Project: Multi-Provider Chat App with Costs

One day a provider changes its API and half the chat tutorials on the internet quietly break. This Python chatbot project is built to survive that: a command line app that talks to any provider through one adapter layer, remembers the conversation, streams the reply as it arrives, returns typed data with Pydantic, and prints exactly what each turn cost. “Program to an interface, not an implementation.” Gang of Four, Design Patterns Last Updated: July 2026 | Tested on: Python ... Read More

LLM Cost Optimization: Tokens, Caching, and Model Tiers

AI features rarely die because the model was not smart enough. They die in a budget review. LLM cost optimization is how you stop that meeting from happening: know what each request costs, cache the prefix you keep resending, batch the jobs nobody is waiting on, and route easy work to cheap models. This post works all four levers in runnable Python, plus a guard that catches runaway spend. “Optimization hinders evolution.” Alan Perlis, Epigrams on Programming Last Updated: July ... Read More

How to Choose an LLM: Open vs Closed, Size, Cost, Licenses

The model at the top of the leaderboard is often the wrong pick for your project. Working out how to choose an LLM means matching a model to the constraints you actually have: budget, latency limits, privacy rules, and the license you can legally ship. This post gives you six plain axes, a decision flowchart, and three honest worked examples so you can stop guessing. “The best model is the cheapest one that passes your own test, not the one ... Read More