---
title: "Why the first token matters"
lesson_id: "01"
---

# Why the first token matters

- **Lesson ID:** 01
- **Goal:** Separate time to first token from total generation time. State why the first token is what the user feels.
- **Human lesson:** [01-why-first-token-matters.html](01-why-first-token-matters.html)

## Prerequisites

- A basic idea that an app can call Apple's Foundation Models API.
- iOS 27 or macOS 27 as the only target.

## Inputs, outputs, and artifacts

- **Inputs:** A language-model request and a user watching the screen.
- **Outputs:** Clear definitions of TTFT and total time.
- **Artifacts:** Two progressive `.flow` diagrams and a Swift clock sketch.

## Agent build steps

1. Say the user judges speed from the first token.
2. Define TTFT and total time as two clocks. Show both clocks around streamResponse.
3. Say streaming shows tokens. It does not by itself lower TTFT.
4. Link the tracer course and the Core AI vs Core ML vs MLX course.

## Constraints

Keep the language simple, friendly, and literal. iOS 27 and macOS 27 only. No quizzes, Mermaid, or em dashes. Do not invent API names. Mark sketches as sketches and tell the reader to confirm them in the Xcode 27 SDK.

## Key concepts

- TTFT is request start to first token. Total time is start to last token.
- Streaming shows tokens as they arrive. It does not make the first token faster.
- The same session type can run on-device or on Private Cloud Compute.
- Slow TTFT may be context packing or a tool, not the model.

## Takeaways

- Quote TTFT and total time as two separate numbers.
- Do not hide a slow start behind a good finish.
- Show the stream, then measure both clocks.

## Acceptance checks

- TTFT and total time are both named.
- Streaming is described as display, not a free speedup.
- Sibling links, progressive `.flow` diagrams, and an Agent brief link are present.
- [ ] Proceed to [lesson 02 brief](02-stream-the-response.llms.md).
