AI Costs: Tokens, Energy, Model Choice & API Keys | Stanford CS193T Lecture 7 with Cynthia Bailey
Stanford Online
Token reports 0:05
Claude code’s usage report breaks out cost, total duration, and token counts. API duration is the time spent waiting for model responses, including network travel and server delay. Wall clock duration is simply elapsed time since the session began. The report also separates input tokens, which include your prompts and the hidden context window, from output tokens, which include both visible replies and any reasoning tokens the model generates.
Cache and overhead 6:00
Cache can reduce the cost of repeated input by reusing precomputed context. It is cheaper because the expensive attention calculation has already been done once and stored. The report also shows how much of your input comes from enabled skills or plugins. Even unused skills still add overhead to every prompt, so keeping only the needed ones helps trim cost and clutter.
Guardrails and response choice 22:00
The tutor workflow uses separate agents for input, response, and output. The input guard rail blocks clear requests for the answer. The response agent then writes a careful reply with citations, examples, or a short Socratic lead-in. The output guard rail checks the final text again, because students may try to work around the first filter and pull too much of the answer from the response step.
API keys and billing 30:01
An API key lets a computer program use a model outside the vendor’s chat app. It works like login credentials, but it is meant for software, not a person. The key ties use to an account and billing plan. That matters when you build a class tool or other shared system, because you can either pay for everyone yourself or ask each user to bring their own key and pay for their own use.
Data center backlash 44:03
Neighbors objected to the loud, water-hungry data centers because cooling overheats the GPUs, and diesel generators add more noise. The issue spread into politics. In 41 ballot measures across 10 states, and 50 measures in 13 states overall, voters treated AI data centers as a major factor.
AI-generated summary. It can be wrong or incomplete - check anything that matters against the original.

