Topic
Framework Cost & Latency Optimization Tutorials
12 posts on framework cost & latency optimization tutorials — part of framework tutorials on the n4n AI blog.
Trim LangChain prompts with tiktoken to save on tokens
Learn to trim LangChain prompts with tiktoken for token savings — step-by-step guide with runnable code and verification methods.
Stream responses in LangGraph to cut perceived latency
Learn to implement streaming responses in LangGraph with step-by-step code examples that cut perceived latency and improve UX for LLM applications.
Speed up RAG retrieval with LlamaIndex reranking models
A hands-on tutorial showing how to integrate LlamaIndex reranking models into RAG pipelines to reduce latency while improving retrieval quality, with runnable code and benchmarks.
Reduce redundant LLM calls in CrewAI agent loops
Practical steps to cut redundant LLM calls in CrewAI agent loops using caching, shared memory, and smarter task design.
Reduce LlamaIndex latency with async query pipelines
Cut LlamaIndex query latency by converting synchronous retrievers and synthesizers to async pipelines with parallel execution and streaming.
Lower per-token costs with LiteLLM request batching
Learn how to implement LiteLLM request batching to cut per-token costs with step-by-step code examples and verification methods.
Cut inference costs with vLLM continuous batching
Learn how vLLM continuous batching reduces inference cost by maximizing GPU utilization, with practical setup, tuning, and measurement steps.
Compress context in LangChain to reduce token costs
Learn to implement langchain context compression reduce tokens techniques with runnable code, token counting, and production patterns for LLM cost optimization.
Prompt caching in LangChain: cut Claude costs by 90%
Hands-on LangChain tutorial: use Anthropic prompt caching with Claude to slash input token costs by 90%. Step-by-step code, usage metrics, and gotchas.
Cut LangChain costs with semantic caching via GPTCache
Step-by-step guide to langchain semantic caching gptcache cost reduction: deploy a semantic cache layer to slash LLM token spend and p95 latency.
Cache embeddings in LlamaIndex to reduce OpenAI API spend
Learn how to implement a LlamaIndex embedding cache to avoid duplicate OpenAI embedding calls, cut token spend, and speed up RAG pipelines.
Automatic model fallback in LiteLLM to cut GPT-4 spend
Implement LiteLLM automatic model fallback to route around GPT-4 limits and slash inference costs. Step-by-step proxy config and code.
More topics in framework tutorials
- Building Chatbots with Vercel AI SDK & Next.js15
- LangChain RAG with Vector Databases15
- LangGraph Multi-Agent Workflows15
- LlamaIndex Query Engines for RAG15
- AutoGen Multi-Agent Conversations & Group Chat14
- Choosing an AI Framework by Use Case14
- CrewAI Agent Roles & Task Design14
- CrewAI Real-World Crew Examples14
- Haystack RAG Pipelines14
- LangChain Agents & Tool Calling14
- LangChain Multi-Model Fallback & Routing14
- LangChain.js for Node & TypeScript14