---
title: "streamResponse(to:options:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/languagemodelsession/streamresponse(to:options:)-2nlni"
---

# streamResponse(to:options:)

Produces a response stream to a prompt.

## Declaration

```swift
final func streamResponse(to prompt: Prompt, options: GenerationOptions = GenerationOptions()) -> sending LanguageModelSession.ResponseStream<String>
```

## Parameters

- `prompt`: A prompt for the model to respond to.
- `options`: Options that control how tokens are sampled from the distribution the model produces.

## Return Value

Return Value A response stream that produces aggregated tokens.

## Discussion

Discussion important: If running in the background, use the non-streaming respond(to:options:) method to reduce the likelihood of encountering LanguageModelError.rateLimited(_:) errors.
