<!--
{
  "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/LanguageModelSession/streamResponse(generating:includeSchemaInPrompt:options:prompt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC14streamResponse10generating21includeSchemaInPrompt7options6promptAC0G6StreamVy_xGxm_SbAA17GenerationOptionsVAA0L0VyKXEtKAA9GenerableRzlF"
  },
  "title" : "streamResponse(generating:includeSchemaInPrompt:options:prompt:)"
}
-->

# streamResponse(generating:includeSchemaInPrompt:options:prompt:)

Produces a response stream to a prompt.

```
final func streamResponse<Content>(generating type: Content.Type = Content.self, includeSchemaInPrompt: Bool = true, options: GenerationOptions = GenerationOptions(), @PromptBuilder prompt: () throws -> Prompt) rethrows -> sending LanguageModelSession.ResponseStream<Content> where Content : Generable
```

## Parameters

`type`

A type to produce as the response.

`includeSchemaInPrompt`

If `true`, injects the schema into the prompt to bias the model.

`options`

Options that control how tokens are sampled from the distribution the model produces.

`prompt`

A prompt for the model to respond to.

## Return Value

A response stream that produces [`GeneratedContent`](/documentation/FoundationModels/GeneratedContent) containing the fields and values defined in the schema.

## Discussion

Consider using the default value of `true` for `includeSchemaInPrompt`.
The exception to the rule is when the model has knowledge about the expected response format, either
because it has been trained on it, or because it has seen exhaustive examples during this session.

> Important: If running in the background, use the non-streaming
> ``doc://com.apple.foundationmodels/documentation/FoundationModels/LanguageModelSession/respond(to:options:)-6a2gb`` method to
> reduce the likelihood of encountering ``doc://com.apple.foundationmodels/documentation/FoundationModels/LanguageModelError/rateLimited(_:)`` errors.

---

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)