File Name: | ByteByteGo - AI Cost Optimization |
Content Source: | |
Genre / Category: | |
Password: |
|
Original Price: | $899 |
Language: | ENGLISH |
ABOUT THE COURSE:
AI Cost Optimization — a practical course by ByteByteGo focused on reducing costs associated with using large language models (LLMs), optimizing AI infrastructure, and increasing the economic efficiency of AI applications and agent systems.
As artificial intelligence is implemented in real products, companies face increasing expenses on API requests, token processing, context storage, and executing multi-step agent processes. Even relatively simple user requests can lead to thousands of paid tokens, and inefficient architecture can significantly increase system operation costs.
This course will teach you to understand where AI costs arise, identify the main sources of overspending, and apply engineering optimization methods without significant loss of quality and performance.
Under the guidance of Jeremy Hintz, engineering lead at Meta, you will study the economics of LLM inference, cost monitoring systems, caching mechanisms, context compression, model distillation, intelligent request routing, and multi-agent workflow optimization.
The training is designed for four weeks and combines theoretical classes with practical assignments, in which you will create your own tools for controlling and reducing AI expenses.
What You Will Learn
Understanding AI Cost Structure
Understanding the cost of input, output, cached, and reasoning tokens.
Realizing why a short request can turn into thousands of paid tokens.
Calculating the cost of individual requests, dialogues, and complex agent tasks.
Analyzing the economics of LLM inference and comparing different payment models.
Tracking and Analyzing Costs
Creating a unified LLM Gateway for centralized AI request management.
Tracking expenses by users, teams, functions, and individual tasks.
Using observability tools to analyze cost, latency, and token usage.
Identifying the most costly system components and prioritizing optimizations.
Reducing Costs Through Caching
Implementing precise and semantic caching of responses.
Using caching of prompts on the provider's side.
Organizing the request structure properly to increase cache efficiency.
Identifying errors leading to unnecessary re-accessing of models.
Optimizing AI Agent Context
Reducing context volume without loss of important information.
Removing outdated tool results and unused data.
Applying strategies for compressing long dialogues and task execution history.
Moving long-term agent memory outside the context window.
Evaluating the impact of context compression on cost and response quality.
Using Smaller Models to Reduce Costs
Identifying tasks that can be handled by less expensive models.
Applying distillation of prompts, context, and models.
Replacing repetitive complex requests with lighter specialized solutions.
Testing the quality of smaller models and monitoring their relevance after system changes.
Creating Intelligent Request Routing
Directing simple tasks to economical models and complex ones to more powerful models.
Developing custom model routers.
Using model cascades to optimize the cost-to-quality ratio.
Creating routing evaluation systems and testing their efficiency in real scenarios.
Optimizing Multi-Agent Systems
Evaluating the cost of multi-step and multi-agent workflows.
Detecting infinite loops, retries, and inefficient task transfers between agents.
Managing agent state and context.
Optimizing the planning and execution of complex tasks.
Reworking inefficient agent systems to reduce costs.
Course Program
Week 1. AI Economics and Cost Monitoring
The first week focuses on the fundamental principles of AI system cost formation and tools for expense analysis.
Main Topics:
LLM cost structure: input, output, cached, batch, and reasoning tokens.
Additional expenses for tools, multimodal data, and embeddings.
Payment models: Pay-as-you-go, dedicated compute, and own infrastructure.
Inference economics and latency metrics.
Cost calculation specificities of agent systems.
Impact of RAG, tool schemas, and multi-agent processes on expenses.
Query tracing and OpenTelemetry.
Token usage, performance, and cost monitoring.
Expense analysis at the user, team, and function levels.
LLM Gateway and tools like LiteLLM, Portkey, Kong, Cloudflare, and OpenRouter.
Observability platforms: Langfuse, LangSmith, Helicone, Arize Phoenix, W&B Weave, and Braintrust.
Identifying the most effective optimization directions.
Practical Assignment: Creating an LLM Gateway for a multi-user system, connecting monitoring via Langfuse, analyzing costs, and implementing the first optimization with before-and-after result measurement.
Week 2. Efficient Token Usage
The second week is dedicated to methods for reducing the number of processed tokens and minimizing repeated computations.
Main Topics:
Caching identical requests.
Semantic caching using embeddings and vector search.
Setting similarity thresholds for cached responses.
Caching prompts on the LLM provider's side.
Typical errors disrupting caching operations.
Compression and cleanup of AI agent contexts.
Removal of outdated tool results.
Context window management.
KV-cache optimization.
Prompt, context, and model distillation.
Distillation method limitations and potential quality losses.
Practical Assignments:
Creating a semantic cache with similarity threshold settings and correctness check of responses.
Developing a prefix prompt caching simulator.
Comparing different context compression strategies with cost and information preservation measurements.
Distilling a complex router into a smaller model followed by testing and retraining.
Week 3. Intelligent Routing and Model Cascades
The third week is about selecting the optimal model for each request considering task complexity, cost, quality, and response time.
Main Topics:
Economics of reasoning models and managing depth of reasoning.
Forecasting user query complexity.
Balancing between cost, quality, and latency.
Model cascades and the FrugalGPT approach.
LLM routing architectures.
Predictive and deterministic routing.
RouteLLM, LiteLLM, OpenRouter, Azure Model Router, and Amazon Bedrock.
Vector routing and selecting models for individual agent steps.
Metrics for evaluating router quality.
Automated testing using LLM-as-a-Judge.
Request distribution monitoring and checking changes in production systems.
Practical Assignment: Developing a custom model router from scratch, testing it on a simulated LLM set, and creating an evaluation system to compare the cost and quality of different routing strategies.
Week 4. Optimization of Agent Workflows
The final week focuses on the most complex scenarios — multi-agent systems where task execution costs can rapidly increase due to repeat requests, improper planning, and inefficient state management.
Main Topics:
Multi-agent system architectures.
Task division, agent specialization, and parallel execution.
Cost models for multi-agent processes.
Detecting infinite loops and uncontrolled retries.
Task transfer issues between agents.
Identifying repetitive actions and lack of progress.
State cleanup and memory management.
Context compression and agent process restarts.
Planning strategies ReAct and Plan-then-Execute.
Solution search optimization and rescheduling.
Speculative decoding.
Joint optimization of models, prompts, tools, and infrastructure.
Capstone Project: Reworking an inefficient research AI agent. You will analyze the reasons for increased costs, identify problematic loops, and apply learned optimization methods to enhance the overall system efficiency.
Who This Course Is For
The course will be useful for:
AI/ML Engineers developing and optimizing applications based on large language models.
Backend Developers integrating LLM APIs into products and services.
AI Engineers creating autonomous agents and multi-agent systems.
MLOps and Infrastructure Engineers responsible for AI infrastructure performance, monitoring, and costs.
Technical Leads and Architects needing to control AI expenses and increase the return on technological investments.
Requirements
No deep prior AI knowledge is required to take the course, although practical experience with AI tools will help you master the material more quickly.
To complete the assignments, you will need an API key from one of the LLM providers, such as OpenAI, Anthropic Claude, or Google Gemini.
Estimated additional API expenses during training are 10–20 dollars.
Learning Outcome
By the end of the course, you will understand how the cost of modern AI systems is formed, be able to identify inefficient use of computing resources, and independently implement cost-reduction methods.
You will gain practical experience in creating an LLM Gateway, implementing caching, context optimization, model distillation, intelligent request routing, and enhancing multi-agent processes.
The main goal of the course is to learn how to create AI systems that maintain the necessary quality and performance while requiring significantly fewer resources to perform the same tasks.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.