> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# max_tokens

> Contract, placement, related fields and source examples for this Nika YAML field.

[Language reference](https://docs.nika.sh/reference/language/overview.md) / `max_tokens`

## Meaning and placement

### infer

Max output tokens · a literal non-negative integer: a `${{ }}` reference is refused at parse (spec/02-verbs.md §infer).

| Property | Declaration |
| - | - |
| Requirement | Optional in this object |
| Schema location | `/$defs/infer/properties/max_tokens` |
| type | `"integer"` |
| minimum | `0` |
| maximum | `4294967295` |

**In the same object:** [model](https://docs.nika.sh/reference/language/words/model.md) · [prompt](https://docs.nika.sh/reference/language/words/prompt.md) · [schema](https://docs.nika.sh/reference/language/words/schema.md) · [system](https://docs.nika.sh/reference/language/words/system.md) · [temperature](https://docs.nika.sh/reference/language/words/temperature.md) · [thinking](https://docs.nika.sh/reference/language/words/thinking.md) · [vision](https://docs.nika.sh/reference/language/words/vision.md)

[Schema source (use the pointer above)](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/schemas/workflow.schema.json)

## In a source template

Excerpt from `templates/agent-loop.nika`, source lines 57–66. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
      # fails NIKA-INFER-002 ("no JSON value found · the reply was cut off at
      # the token limit"). Measured — 400 starves qwen3.5:4b on this prompt.
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
      max_tokens: 2000
      schema:
        type: object
        additionalProperties: false
        required: [steps]
        properties:
          steps: { type: array, items: { type: string } }
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/agent-loop.nika` | [Line 60](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/agent-loop.nika#L60) |
| `templates/bounded-batch.nika` | [Line 58](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/bounded-batch.nika#L58) |
| `templates/chain.nika` | [Line 67](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/chain.nika#L67) |
| `templates/classify-and-route.nika` | [Line 79](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/classify-and-route.nika#L79) |
| `templates/corpus-qa.nika` | [Line 99](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/corpus-qa.nika#L99) |
| `templates/docker-report.nika` | [Line 71](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/docker-report.nika#L71) |
| `templates/document-to-fields.nika` | [Line 60](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/document-to-fields.nika#L60) |
| `templates/evaluate-and-optimize.nika` | [Line 41](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/evaluate-and-optimize.nika#L41) |
| `templates/fanout.nika` | [Line 126](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/fanout.nika#L126) |
| `templates/media-asset-pack.nika` | [Line 54](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/media-asset-pack.nika#L54) |
| `templates/parallel-review.nika` | [Line 78](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/parallel-review.nika#L78) |
| `templates/project-public-fields.nika` | [Line 83](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/project-public-fields.nika#L83) |
| `templates/website-brief.nika` | [Line 64](https://github.com/supernovae-st/nika-spec/blob/5c40ba456c53a4ab663a949d44003078e161305d/templates/website-brief.nika#L64) |

These are literal key occurrences in the source files, not an execution or conformance claim. [How to instantiate a template](https://docs.nika.sh/guides/templates.md).

## Contract and implementation

This page projects the named specification revision. Check [released engine status](https://docs.nika.sh/reference/status.md) and [the validation workflow](https://docs.nika.sh/guides/agent-authoring.md) before running a file. An optional field is not evidence that every engine supports every value.

Canonical identity: `language:word:max_tokens`. Spec revision: [`5c40ba456c53`](https://github.com/supernovae-st/nika-spec/tree/5c40ba456c53a4ab663a949d44003078e161305d).

[How documentation stays connected](https://docs.nika.sh/reference/knowledge-system.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.