The Claude Models

Anthropic offers several Claude models; pick one by balancing capability, speed, and cost.

Claude comes in several models. They all use the same Messages API — you choose one by setting the model field in your request.

The current family

ModelModel IDBest for
Claude Opus 4.8claude-opus-4-8The most capable Opus-tier model — hard reasoning, long agentic coding tasks.
Claude Sonnet 5claude-sonnet-5Great balance of quality and cost for high-volume production work.
Claude Haiku 4.5claude-haiku-4-5-20251001Fast and cheap — classification, short replies, simple tasks.
Claude Fable 5claude-fable-5Anthropic's most capable model for the most demanding work.

How to choose

  • Default to a capable model (Opus or Sonnet) while building — quality first.
  • Drop to Haiku for cheap, fast tasks that run at high volume.
  • Only change the model string — the rest of your code stays the same.

Example

Example · json
{
  "pick_a_model": {
    "building_an_app": "claude-opus-4-8",
    "high_volume_production": "claude-sonnet-5",
    "cheap_fast_classification": "claude-haiku-4-5-20251001",
    "hardest_tasks": "claude-fable-5"
  }
}

When to use it

  • Route quick FAQ answers to claude-haiku-4-5 to keep latency under 500 ms and cost near zero.
  • Use claude-sonnet-4-5 for complex code generation tasks where accuracy matters more than speed.
  • Switch to claude-opus-4-5 only for the most demanding reasoning tasks, such as multi-step financial analysis.

More examples

Selecting Haiku for fast autocomplete

Uses the fastest, cheapest model for a latency-sensitive autocomplete feature.

Example · javascript
const msg = await client.messages.create({
  model: "claude-haiku-4-5",
  max_tokens: 32,
  messages: [{ role: "user", content: "Autocomplete: The user wants to" }],
});

Sonnet for structured code generation

Targets the balanced model for a task that needs solid reasoning without maximum cost.

Example · javascript
const msg = await client.messages.create({
  model: "claude-sonnet-4-5",
  max_tokens: 1024,
  messages: [{
    role: "user",
    content: "Generate a React hook that debounces a value by 300 ms."
  }],
});

Model name as an env variable

Externalises the model name so it can be changed per environment without code edits.

Example · javascript
const MODEL = process.env.CLAUDE_MODEL ?? "claude-sonnet-4-5";
const msg = await client.messages.create({
  model: MODEL,
  max_tokens: 512,
  messages: [{ role: "user", content: prompt }],
});

Discussion

  • Be the first to comment on this lesson.