<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/LanguageModelSession/respond(to:options:contextOptions:metadata:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC7respond2to7options14contextOptions8metadataAC8ResponseVy_SSGAA6PromptV_AA010GenerationJ0VAA07ContextJ0VSDySSAA29ConvertibleToGeneratedContent_pGtYaKF::OverloadGroup"
  },
  "title" : "respond(to:options:contextOptions:metadata:)"
}
-->

# respond(to:options:contextOptions:metadata:)

Produces a response to a prompt.

```
@discardableResult nonisolated(nonsending) final func respond(to prompt: Prompt, options: GenerationOptions = GenerationOptions(), contextOptions: ContextOptions = ContextOptions(), metadata: [String : any ConvertibleToGeneratedContent] = [:]) 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.

`contextOptions`

Settings that configure how the model is prompted.

`metadata`

Metadata to attach to the request.

## Return Value

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

---

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)