Counting Tokens and Estimating Costs When Calling LLMs in Java
How to count tokens locally with JTokkit, calculate costs with BigDecimal, block requests exceeding budget, and reconcile with actual usage from Spring AI.
How to count tokens locally with JTokkit, calculate costs with BigDecimal, block requests exceeding budget, and reconcile with actual usage from Spring AI.
Receive tokens from LLM API via Server-Sent Events using HttpClient and WebClient, then push to browsers, with error handling, timeouts, and tests.
Understand how LLMs call application functions, from raw JSON to @Tool in Spring AI. Includes examples for order lookup, cancellation, and testing without calling the model.
How to force LLM to return JSON matching schema in Spring Boot: map to record with Spring AI, enable native JSON Schema, validate, retry and write tests.
Practical prompt engineering techniques like system prompt, delimiter, few-shot, structured output, and temperature, illustrated with Spring AI.
Understand how temperature, top_p, and max_tokens control LLM output, and configure them correctly with Spring AI in Spring Boot 3 applications.
Understand three foundational LLM concepts: tokens, context window, and sampling. With Java 21 code to count tokens, trim chat history, and tune temperature, top-k, top-p yourself.
Distinguish the three MCP primitives—tool, resource, and prompt—by who controls them, with Spring AI examples and tests for each type.
Build a complete RAG pipeline with Spring AI: chunk documents, create embeddings, vector search, augment prompts with sources, and test each step.
Create vector embeddings using sentence-transformers, calculate similarity, perform semantic search, and call the model from a Spring Boot application.
Understand the essence of AI Agents through the observe-reason-act loop, build a minimal agent from scratch in Java 21, and test it with JUnit 5.
Analyze the architectural patterns behind the hottest AI agent repos on GitHub 2026, with an example of building your own Tool-Calling Agent using Java/Spring Boot.
Define AI Agent, distinguish from typical chatbots, explain the ReAct loop, and build a minimal agent in Java and Spring AI.
Analyzing a production-grade AI architecture that can run at zero cost, from frontend, RAG, local LLM to deployment, with hands-on code examples.
Explore 5 common patterns for building AI Agents – Reflection, Tool Use, Planning, Multi-Agent, ReAct – with runnable Java/Spring AI examples.
A guide to building a minimal MCP server with Java 21, registering your first tool, and connecting with a client like Claude Desktop.
Guide to fine-tuning a small model (DistilBERT) for product review classification using Hugging Face's Trainer API, from data preparation to inference.
Explains the simultaneous listen-speak (full-duplex) architecture of real-time LLM models, with WebSocket integration examples using Spring Boot.
Guide to using Hugging Face's Datasets library to load, explore, transform, and save datasets for NLP model training.
LLMs don't inherently know your company's private data. This article explains RAG mechanics, why retrieval determines answer quality, with working Java examples.