Skip to main content

LLM Cheatsheet

At a glance​

What it isLarge language models: next-token predictors used via API (or local open weights) for text, code, extraction and agents
Use it forChat/assistants, summarization, extraction to JSON, classification, code generation, RAG over your docs, tool-using agents
Latest stableAnthropic: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1. Google: Gemini 4 Argon (gemini-4-argon, GA 2026-10-13). OpenAI: GPT-6 Astra (gpt-6-astra). SDK versions in the table below - checked 2026-10-31
Official docsClaude · OpenAI · Gemini · MCP

SDKs and spec (checked 2026-10-31)

PackageRegistryLatestReleased
@anthropic-ai/sdknpm1.3.02026-10-23
openainpm7.47.02026-10-31
@google/genainpm2.32.02026-10-29
@modelcontextprotocol/sdknpm1.32.22026-10-23
anthropicPyPI2.3.02026-10-23
openaiPyPI3.42.02026-10-31
google-genaiPyPI2.34.02026-10-29
mcpPyPI2.3.02026-10-02
MCP specificationGitHub releases2026-07-282026-07-28

Core concepts​

  • Token: the unit models read, write and bill; roughly a word piece, not a character.
  • Context window: max tokens per request (input + output); the model sees only what you send.
  • System prompt: role, rules and format instructions that frame every turn.
  • Sampling: temperature / top-p trade determinism for variety; some reasoning models restrict them.
  • Structured output: constrain the reply to a JSON schema instead of parsing free text.
  • Tool calling: the model asks your code to run a function; you return the result; it continues.
  • RAG: retrieve relevant chunks (embeddings + search) and put them in the prompt.
  • Agent: a loop of model + tools running until the task is done.
  • MCP: open protocol for exposing tools/resources/prompts to any LLM app.
  • Evals: automated tests for prompts and models; the only reliable way to compare changes.

Syntax & commands​

npm i @anthropic-ai/sdk openai @modelcontextprotocol/sdk
pip install anthropic openai google-genai
export ANTHROPIC_API_KEY=... # SDKs read keys from env
export OPENAI_API_KEY=...
// Anthropic Messages API
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic();
const msg = await anthropic.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 1024,
system: "You are a concise senior engineer.",
messages: [{ role: "user", content: "Explain idempotency in 2 lines." }],
});
console.log(msg.content[0].type === "text" ? msg.content[0].text : msg.content);
// OpenAI Responses API
import OpenAI from "openai";
const openai = new OpenAI();
const res = await openai.responses.create({
model: process.env.OPENAI_MODEL!, // pick a current id from the OpenAI models page
instructions: "You are a concise senior engineer.",
input: "Explain idempotency in 2 lines.",
});
console.log(res.output_text);
# Anthropic, Python
import anthropic
client = anthropic.Anthropic()
msg = client.messages.create(
model="claude-haiku-5-5",
max_tokens=512,
messages=[{"role": "user", "content": "Classify: 'refund please' -> intent?"}],
)
print(msg.content[0].text)

Common patterns​

NeedPattern
Reliable JSONStructured outputs with a JSON schema (Anthropic output_config.format) + validate anyway
Use your dataRAG: chunk → embed → retrieve (hybrid) → rerank → cite
Take actionsTool calling loop; keep tools small, typed, idempotent
Reuse tools across appsWrap them in an MCP server
Cheap + fastSmall model for routing/classification, big model only when needed
Long repeated prefixPrompt caching (stable content first, variable content last)
Bulk offline jobsBatch API (Anthropic batches are 50% off)
Responsive UIStream tokens
Prevent regressionsEval set in CI before shipping prompt/model changes

Gotchas​

  • max_tokens is required on Anthropic and caps output; truncated replies end with stop_reason: "max_tokens".
  • Models are stateless: resend history every turn (and pay for it).
  • Never trust model output as code or SQL without validation; never put secrets in prompts.
  • Retrieved web pages, emails and files can contain prompt injection - treat them as data.
  • Newer reasoning models may reject or ignore temperature/top_p; check the model page.
  • Model IDs get retired; pin an ID and track deprecation pages.
  • Token counts differ per tokenizer/vendor - do not reuse estimates across models.

What's new in recent releases​

  • Claude 5.5 family (Opus, Sonnet, Haiku) plus Claude Fable 5.1 for the hardest reasoning/agentic work; all current Claude models list a 1M-token context window.
  • Adaptive thinking + effort on current Claude models replaces manual extended thinking with budget_tokens.
  • Structured outputs are GA on the Claude API under output_config.format; the old beta output_format is deprecated.
  • Automatic prompt caching: a top-level cache_control on the Claude Messages request moves the breakpoint forward as the conversation grows.
  • MCP spec 2026-07-28: stateless request/response protocol (no initialize handshake or Mcp-Session-Id), multi round-trip requests, extensions framework; breaking for SDKs that relied on sessions.
  • Gemini 4 Argon is GA on the Gemini API (2026-10-13).
  • Major SDK bumps: @anthropic-ai/sdk 1.x, npm openai 7.x, @google/genai 2.x, PyPI mcp 2.x - read migration notes before upgrading.

In these notes​