<!--
{
  "availability" : [
    "iOS: 26.0.0 - 27.0.0",
    "iPadOS: 26.0.0 - 27.0.0",
    "macCatalyst: 26.0.0 - 27.0.0",
    "macOS: 26.0.0 - 27.0.0",
    "visionOS: 26.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/LanguageModelSession/GenerationError/refusal(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Foundation Models"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC15GenerationErrorO7refusalyA2E7RefusalV_AE7ContextVtcAEmF"
  },
  "title" : "LanguageModelSession.GenerationError.refusal(_:_:)"
}
-->

# LanguageModelSession.GenerationError.refusal(_:_:)

An error indicating that the model refused to answer.

```
case refusal(LanguageModelSession.GenerationError.Refusal, LanguageModelSession.GenerationError.Context)
```

## Discussion

This error can happen for prompts that do not violate any guardrail policy, but
the model isn’t able to provide the kind of response you requested. You can
choose to handle this error by showing a predetermined message of your choice,
or you can use the `Refusal` to generate an explanation from the model itself.

---

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)