<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/LanguageModelSession/GenerationError/Refusal",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC15GenerationErrorO7RefusalV"
  },
  "title" : "LanguageModelSession.GenerationError.Refusal"
}
-->

# LanguageModelSession.GenerationError.Refusal

A refusal produced by a language model.

```
struct Refusal
```

## Overview

Refusal errors indicate that the model chose not to respond to a prompt. To make the model
explain why it refused, catch the refusal error and access one of its explanation properties.

```swift
do {
    let session = LanguageModelSession()
    let response = try session.respond(to: "...")
} catch error as LanguageModelSession.GenerationError.refusal(let refusal, _) {
    let message = try await refusal.explanation
    print(message)
} catch {
    print("Something went wrong: \(error)")
}
```

## Topics

### Creating a generation error refusal

[`init(transcriptEntries:)`](/documentation/FoundationModels/LanguageModelSession/GenerationError/Refusal/init(transcriptEntries:))

### Getting the explanation

[`explanation`](/documentation/FoundationModels/LanguageModelSession/GenerationError/Refusal/explanation)

An explanation for why the model refused to respond.

[`explanationStream`](/documentation/FoundationModels/LanguageModelSession/GenerationError/Refusal/explanationStream)

A stream containing an explanation about why the model refused to respond.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)