Skip to content
Guest
AI Engineering · Course Syllabus Show lessons
LLM Foundations · 9 min read · Intermediate

LLM APIs, Tokens & Context Windows

Understand how LLMs process tokens, system vs user messages, temperature, and context window pricing.

What you'll learn

  • Estimate token counts and API cost per 1M input/output tokens
  • Separate system instructions from untrusted user input
  • Tune temperature and max_output_tokens for deterministic tasks

Overview

Understand how LLMs process tokens, system vs user messages, temperature, and context window pricing.

Code Example

const payload = {
  model: "gemini-2.5-flash",
  temperature: 0.2,
  messages: [
    { role: "system", content: "You are a concise SQL code reviewer." },
    { role: "user", content: "Review: SELECT * FROM users;" }
  ]
};

Key Takeaways

  • Estimate token counts and API cost per 1M input/output tokens
  • Separate system instructions from untrusted user input
  • Tune temperature and max_output_tokens for deterministic tasks

Quick Check

Check Your Understanding

Score: 0 / 1

1. Why should production extraction or classification tasks use a low temperature (e.g. 0.0 to 0.2)?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind