Learn structured outputs for LLMs: get reliable JSON from OpenAI and Ollama using Pydantic and Zod schemas, plus validation and retry in Python and Node.js.
Continue reading...Generative AI
Generative AI Part 7: How to Stream LLM Responses and Build a Simple Chat UI
Learn how to stream LLM responses in Python and Node.js, read Server-Sent Events and build a simple chat UI with memory and a Stop button for Ollama or OpenAI.
Continue reading...Generative AI Part 6: How to Run LLMs Locally with Ollama
Learn to run LLMs locally with Ollama: install it, pull open models, chat in the terminal and call them from Python and Node.js. Free, private and offline.
Continue reading...Generative AI Part 5: Temperature and Top-p for Controlling Model Output
Learn temperature and top-p for LLMs: how sampling works, plus top-k, max tokens, stop sequences and which GPT-6 and Claude models accept them, with code.
Continue reading...Generative AI Part 4: Prompt Engineering Basics with Roles, Instructions and Examples
Learn prompt engineering basics: system and user roles, clear instructions, XML tags, few-shot examples and prompt templates, with Python and Node.js code.
Continue reading...Generative AI Part 3: Your First LLM API Calls in Python and Node.js
Make your first LLM API calls in Python and Node.js with OpenAI, Claude and Gemini. Learn API keys, requests, token usage, errors and cost, step by step.
Continue reading...Generative AI Part 2: Tokens, Context Windows and Model Parameters
Learn what tokens, the LLM context window and model parameters mean, with Python and Node.js code to count tokens, trim chat history and estimate memory.
Continue reading...Generative AI Part 1: What Is Generative AI and How Do LLMs Work?
What is generative AI? Learn how LLMs work through next-token prediction, tokens and training, then run your first Python, Node.js and free local model code.
Continue reading...