---
title: "tokenCount(for:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/systemlanguagemodel/tokencount(for:)"
---

# tokenCount(for:)

Returns the token count for the specified instructions.

## Declaration

```swift
nonisolated(nonsending) final func tokenCount(for instructions: Instructions) async throws -> Int
```

## Parameters

- `instructions`: The instructions to calculate the token count for.

## Mentioned in

Managing the context window

## Return Value

Return Value The token count for the instructions.
