Real World Example

Autocomplete in Products

Next-token prediction is directly visible in GitHub Copilot code completion, Gmail Smart Compose and Notion AI "continue writing". The editor sends the text before the cursor; the model continues it. Here is a ShopEase admin feature that continues a half-written product description:

import anthropic

client = anthropic.Anthropic()

draft = "Handwoven cotton kurta in indigo blue. Breathable fabric, ideal for"

response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=120,
    system="You continue product descriptions for an Indian e-commerce store. "
           "Return only the continuation (1-2 sentences), no quotes, no preamble.",
    messages=[{"role": "user", "content": f"Continue this text:\n{draft}"}],
)
print(draft, response.content[0].text)
print("stop_reason:", response.stop_reason, "| output tokens:", response.usage.output_tokens)

Run it

python continue_description.py

Example output

Handwoven cotton kurta in indigo blue. Breathable fabric, ideal for summer office days and festive evenings alike. Pair it with white churidar or jeans for an easy, elegant look.
stop_reason: end_turn | output tokens: 31

Things to Notice

  • The model writes fluent text but knows nothing about the actual kurta: a seller must review claims like "breathable" (hallucination risk).
  • stop_reason is end_turn: the model decided it was done. If it were max_tokens the text was cut off.