<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/GenerationOptions/maximumResponseTokens",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation Models"
    ],
    "preciseIdentifier" : "s:16FoundationModels17GenerationOptionsV21maximumResponseTokensSiSgvp"
  },
  "title" : "maximumResponseTokens"
}
-->

# maximumResponseTokens

The maximum number of tokens the model is allowed to produce in its response.

```
var maximumResponseTokens: Int?
```

## Discussion

If the model produce `maximumResponseTokens` before it naturally completes its response,
the framework terminates the response early, without throwing an error. Use this property
to protect against unexpectedly verbose responses and runaway generations.

If no value is specified, then the model is allowed to produce the longest answer
its context size supports. If the response exceeds that limit without terminating,
the framework throws an error.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)