---
title: "respond(to:options:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/languagemodelsession/respond(to:options:)"
---

# respond(to:options:)

Produces a response to a prompt.

## Declaration

```swift
@discardableResult nonisolated(nonsending) final func respond(to prompt: Prompt, options: GenerationOptions = GenerationOptions()) async throws -> LanguageModelSession.Response<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.

## Mentioned in

Optimizing key-value caching in language model sessions Composing dynamic sessions with instructions and profiles Supporting languages and locales with Foundation Models

## Return Value

Return Value A string composed of the tokens produced by sampling model output.

## See Also

### Generating a response

- [isResponding](foundationmodels/languagemodelsession/isresponding.md)
- [respond(options:prompt:)](foundationmodels/languagemodelsession/respond(options:prompt:).md)
- [respond(generating:includeSchemaInPrompt:options:prompt:)](foundationmodels/languagemodelsession/respond(generating:includeschemainprompt:options:prompt:).md)
- [respond(schema:includeSchemaInPrompt:options:prompt:)](foundationmodels/languagemodelsession/respond(schema:includeschemainprompt:options:prompt:).md)
- [respond(to:generating:includeSchemaInPrompt:options:)](foundationmodels/languagemodelsession/respond(to:generating:includeschemainprompt:options:).md)
- [respond(to:schema:includeSchemaInPrompt:options:)](foundationmodels/languagemodelsession/respond(to:schema:includeschemainprompt:options:).md)
- [LanguageModelSession.Response](foundationmodels/languagemodelsession/response.md)
