n4nAI

Topic

Framework Cost & Latency Optimization Tutorials

12 posts on framework cost & latency optimization tutorials — part of framework tutorials on the n4n AI blog.

Framework tutorialsHow-to

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.

4 min read
Framework tutorialsHow-to

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.

4 min read
Framework tutorialsTutorial

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.

3 min read
Framework tutorialsHow-to

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.

5 min read
Framework tutorialsHow-to

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.

3 min read
Framework tutorialsHow-to

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.

4 min read
Framework tutorialsGuide

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.

5 min read
Framework tutorialsTutorial

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.

4 min read
Framework tutorialsTutorial

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.

3 min read
Framework tutorialsHow-to

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.

3 min read
Framework tutorialsTutorial

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.

3 min read
Framework tutorialsHow-to

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.

4 min read