Paths/AI Engineer/LLM Fundamentals / Tokens and Context Windows
Set a Token Budget
Every LLM API call carries two cost knobs — which model you call and how many tokens it may generate. Write a small config file that captures both, the way real applications do.
Validator
IDLE — checks run live as you type commands; submit when done
01Requirements
live checks- Directory ~/llm-lab exists○
- File ~/llm-lab/config.txt exists with a model line and a max_tokens line○
02Walkthrough
5 steps- 01
Create the llm-lab directory
mkdir makes a new directory. Everything you build in this topic lives inside ~/llm-lab — the ~ is shorthand for your home directory, /home/learner.
mkdir ~/llm-lab - 02
Write the model setting
echo prints text and the > redirect writes it into a file, creating it if needed. The first line names the model to call — gpt-4o-mini is a small, cheap model, a sensible default for experiments.
echo model=gpt-4o-mini > ~/llm-lab/config.txt - 03
Append the token budget
A single > overwrites a file, so a second line needs >> — the append redirect. It adds the new text on the next line instead of replacing what is there. max_tokens caps how much the model may generate per call, which caps the cost.
echo max_tokens=1024 >> ~/llm-lab/config.txt - 04
Read the config back
cat prints a file's contents. You should see both lines — the model choice and the token budget.
cat ~/llm-lab/config.txt - 05
Submit for validation
The validator checks that config.txt exists and contains the max_tokens=1024 setting.
03Stuck?
0 of 3 revealedTake a hint without losing the lab — each one points at the thing to look at, not at the answer.
04AI Tutor
guides, never solvesTell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?
04Notebook
saved locally in this browserlearner@lab — ubuntu:24.04
Session is disposable
↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list