Skip to main content

Understanding Costs

Module: Cost & Safety | Lesson: 1 of 3 | Time: ~10 minutes

What You Will Learn

  • How Claude Code pricing works (tokens in, tokens out)
  • How to check your spending with /cost
  • What actions drive cost up and how billing works

Prerequisites

How Claude Code Pricing Works

Every time you interact with Claude Code, you are sending and receiving tokens. Tokens are the units that language models use to process text. Understanding tokens is the foundation of understanding costs.

What Is a Token?

A token is roughly 0.75 words (or about 4 characters of English text). Here are some examples:

TextApproximate Tokens
"Hello"1 token
"Hello, how are you?"6 tokens
A 500-word essay~670 tokens
A typical source code file (200 lines)~800-1,500 tokens
A full conversation (30 exchanges)~10,000-50,000 tokens

You are charged for two types of tokens:

  • Input tokens -- everything you send to Claude: your prompt, the files Claude reads, conversation history, and system context
  • Output tokens -- everything Claude sends back: its responses, code it generates, and tool call results
info

Output tokens are more expensive than input tokens. This means a long, detailed response from Claude costs more than a short one. Being specific in your prompts (so Claude can give concise answers) saves money.


What Drives Cost

Not all interactions cost the same. Here are the biggest cost drivers, from most expensive to least:

1. Long Conversations

Every time you send a new message, Claude receives the entire conversation history as input. This means:

  • Message 1: Claude reads your first message (small cost)
  • Message 2: Claude reads messages 1 + 2 (medium cost)
  • Message 10: Claude reads all 10 messages plus all responses (large cost)
  • Message 30: Claude reads everything (very large cost)

The cost of a conversation grows faster than linearly because each new message includes all previous ones.

2. Large Files

When Claude reads a file, the entire file contents become input tokens. A 1,000-line file might be 5,000+ tokens. If Claude reads several large files in a conversation, the token count climbs quickly.

3. Many Tool Calls

Each time Claude uses a tool (Read, Write, Edit, Bash, Grep, etc.), there is overhead -- the tool request and result add tokens to the conversation. A task that involves 20 tool calls costs more than one that involves 3.

4. Repeated Context

If you paste the same large block of text multiple times, or ask Claude to re-read the same file repeatedly, you pay for those tokens each time.


The /cost Command

Claude Code has a built-in command that shows you exactly what you have spent. During an interactive session, type:

/cost

Claude will display:

  • Session cost -- how much the current conversation has cost so far
  • Total cost -- your cumulative spending across all sessions (for API billing)
tip

Make it a habit to check /cost periodically during long sessions. It only takes a second and helps you stay aware of your spending.

Try it right now. Start a Claude Code session, have a brief conversation (2-3 messages), and then type /cost. Note the amount. Continue the conversation for a few more messages, then check /cost again. You will see the number grow.


Max Subscription vs API Billing

There are two main ways to pay for Claude Code:

Claude Max Subscription

  • Fixed monthly fee (check Anthropic's website for current pricing)
  • Includes a generous allowance of Claude Code usage
  • Best for individuals who use Claude Code regularly
  • You do not pay per token -- it is included in the subscription
  • There may be usage limits during peak times

API Billing (Pay-As-You-Go)

  • You pay for exactly what you use, billed per token
  • Requires an Anthropic API key
  • Pricing varies by model (check Anthropic's pricing page for current rates)
  • Best for automation, CI/CD, and high-volume usage
  • No throttling -- you get what you pay for
Which should I use?

If you are following this tutorial as an individual learner, the Max subscription is likely the most cost-effective option. If you are building automation scripts or CI/CD pipelines (as covered in Module 11), you will need API billing for those headless calls.


Typical Session Costs (API Billing)

Here are rough estimates to give you a sense of what things cost on API billing. These are approximations -- actual costs depend on the model, prompt length, and response length:

ActivityApproximate Cost
A quick question (1 exchange)$0.01 - $0.03
A short conversation (5 exchanges)$0.05 - $0.15
A medium session (15 exchanges)$0.15 - $0.50
A long session (30+ exchanges)$0.50 - $2.00+
Reading a large file (1,000 lines)$0.01 - $0.05 per read
Batch processing 20 files (headless)$0.20 - $1.00
warning

These are rough estimates. Costs can be higher if your conversations involve large files, many tool calls, or very long responses. Always use /cost to check your actual spending.


Try It Yourself

  1. Check your session cost. Start a Claude Code session and immediately type /cost. Note the starting amount (it may be zero or near zero).

  2. Have a short conversation. Ask Claude 3-4 simple questions. Then check /cost again. Note how much it increased.

  3. Read a file and check cost. Ask Claude to read a file (any file in your project). Check /cost before and after. Notice the increase from reading the file.

  4. Mental math. Based on the /cost readings, estimate how much a 30-minute work session would cost you. Is this within your budget?

  5. Check your billing method. Do you know whether you are on a Max subscription or API billing? If not, check your Anthropic account settings.


What You Learned

  • Claude Code costs are based on tokens -- roughly 0.75 words per token
  • You pay for both input tokens (what you send) and output tokens (what Claude sends back)
  • The biggest cost drivers are long conversations, large files, and many tool calls
  • The /cost command shows your current session and total spending
  • Max subscription is a fixed monthly fee; API billing is pay-per-token
  • Typical session costs range from a few cents to a few dollars depending on complexity

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →

Next Up

Next: Cost Optimization Strategies