---
title: "count tokens · RUAL Documentation"
description: "Count the input tokens a prompt (with system + attachments) would use, and estimate the cost; before you send it. Free; no spend."
canonical: https://docs.rual.nl/block-types/anthropic/anthropicconnection_count_tokens
language: en
---

# count tokens

This block is part of the [`anthropic`](https://docs.rual.nl/block-types/anthropic) group and was last modified in core [`v15.0.0`](https://docs.rual.nl/core-versions/150000).

Count the input tokens a prompt (with system + attachments) would use, and estimate the cost; before you send it. Free; no spend.

- flow `flow`

- connection required `anthropicconnection`

- prompt `value` The user message to measure.

- system `value` Optional system prompt to include in the count.

- attachments `file` Optional images/PDFs; their tokens are counted by the API too.

- model `value` Model to price against. Defaults to the connection's default model. • Suggestions: `claude-opus-4-8` `claude-sonnet-4-6` `claude-haiku-4-5`

- max tokens `number` Max output tokens, for the worst-case output cost estimate. Default 16000.

- flow `flow`

- connection `anthropicconnection`

- success `condition`

- model `value`

- input tokens `number` Tokens the prompt + system + attachments would use.

- max tokens `number` The max output tokens used for the output-cost estimate.

- input cost (USD) `number` Cost of the counted input tokens.

- max output cost (USD) `number` Worst-case output cost if generation used the full max_tokens.

- estimated total (USD) `number` input cost + max output cost (the upper bound for a single call).

- errors `array ` Error codes when the call fails (success=false): config_error, rate_limited, transport_error.

- warnings `array ` Non-fatal notices: cost_unknown (model not in the price table; costs reported as 0).

- error detail `value`

| `token count` |
| --- |
| `estimate cost` |
| `tokens` |
| `price check` |
| `how much` |

A typical wiring for [count tokens](https://docs.rual.nl/block-types/anthropic/anthropicconnection_count_tokens): a [function trigger](https://docs.rual.nl/block-types/globals/trigger_custom_function) starts the flow; the `flow` out pin feeds [debug](https://docs.rual.nl/block-types/state%20ui/state_debug).

![Studio canvas example for the count tokens block: typical wiring for count tokens.](https://docs.rual.nl/canvas-examples/anthropicconnection_count_tokens.png)

### Version history

Introduced in [`v15.0.0`](https://docs.rual.nl/core-versions/150000).
