# tinker_cookbook.completers.TinkerTokenCompleter ## *class* [**tinker_cookbook.completers.TinkerTokenCompleter**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L88)(*[TokenCompleter](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/completers/tokencompleter/index.md)*) Token completer that uses a tinker.SamplingClient to sample actions. ```python completer = TinkerTokenCompleter(sampling_client, max_tokens=512) result = await completer(model_input, stop=["<|endoftext|>"]) print(result.tokens, result.logprobs) ``` **Fields:** - [**sampling_client**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L108) (*tinker.[SamplingClient](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/samplingclient/index.md)*) - [**max_tokens**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L109) (*int*) - [**temperature**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L110) (*float*, default: `1.0`) - [**context_window**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L111) (*int | None*, default: `None`) ### [**__call__**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L113)(*model_input*, *stop*, *max_tokens*) Sample an action from the policy given an observation. A per-call `max_tokens` override is combined with the completer's own `max_tokens` by taking the minimum, and the `context_window` cap (when configured) still applies on top. **Parameters:** - [**model_input**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L115) (*tinker.[ModelInput](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/types/modelinput/index.md)*) - [**stop**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L116) (*StopCondition*) - [**max_tokens**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/completers.py#L118) (*int | None*) **Returns:** *[TokensWithLogprobs](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/completers/tokenswithlogprobs/index.md)*