> ## 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](/reference/language/overview) / `max_tokens`

## Meaning and placement

### infer

The schema declares this field at the location below.

| Property        | Declaration                          |
| --------------- | ------------------------------------ |
| Requirement     | Optional in this object              |
| Schema location | `/$defs/infer/properties/max_tokens` |
| type            | \["integer", "string"]               |

**In the same object:** [model](/reference/language/words/model) · [prompt](/reference/language/words/prompt) · [schema](/reference/language/words/schema) · [system](/reference/language/words/system) · [temperature](/reference/language/words/temperature) · [thinking](/reference/language/words/thinking) · [vision](/reference/language/words/vision)

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

## In a source template

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

```yaml illustration theme={"system"}
      # it emits the first brace, and a ceiling that cuts it off mid-thought
      # 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.
      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.yaml`            | [Line 64](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/agent-loop.nika.yaml#L64)            |
| `templates/chain.nika.yaml`                 | [Line 66](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/chain.nika.yaml#L66)                 |
| `templates/classify-and-route.nika.yaml`    | [Line 79](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/classify-and-route.nika.yaml#L79)    |
| `templates/corpus-qa.nika.yaml`             | [Line 99](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/corpus-qa.nika.yaml#L99)             |
| `templates/docker-report.nika.yaml`         | [Line 73](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/docker-report.nika.yaml#L73)         |
| `templates/document-to-fields.nika.yaml`    | [Line 60](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/document-to-fields.nika.yaml#L60)    |
| `templates/evaluate-and-optimize.nika.yaml` | [Line 41](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/evaluate-and-optimize.nika.yaml#L41) |
| `templates/fanout.nika.yaml`                | [Line 129](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/fanout.nika.yaml#L129)              |
| `templates/media-asset-pack.nika.yaml`      | [Line 55](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/media-asset-pack.nika.yaml#L55)      |
| `templates/website-brief.nika.yaml`         | [Line 65](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/website-brief.nika.yaml#L65)         |

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

## Contract and implementation

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

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

[How documentation stays connected](/reference/knowledge-system).
