<!--
{
  "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(options:contextOptions:metadata:prompt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels20LanguageModelSessionC7respond7options14contextOptions8metadata6promptAC8ResponseVy_SSGAA010GenerationI0V_AA07ContextI0VSDySSAA29ConvertibleToGeneratedContent_pGAA6PromptVyKXEtYaKF"
  },
  "title" : "respond(options:contextOptions:metadata:prompt:)"
}
-->

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

Produces a response to a prompt.

```
@discardableResult nonisolated(nonsending) final func respond(options: GenerationOptions = GenerationOptions(), contextOptions: ContextOptions = ContextOptions(), metadata: [String : any ConvertibleToGeneratedContent] = [:], @PromptBuilder prompt: () throws -> Prompt) async throws -> LanguageModelSession.Response<String>
```

## Parameters

`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.

`prompt`

A prompt for the model to respond to.

## 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)