---
title: "respond(generating:options:contextOptions:metadata:prompt:)"
framework: foundationmodels
role: symbol
role_heading: Instance Method
path: "foundationmodels/languagemodelsession/respond(generating:options:contextoptions:metadata:prompt:)"
---

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

Produces a generable object as a response to a prompt.

## Declaration

```swift
@discardableResult nonisolated(nonsending) final func respond<Content>(generating type: Content.Type = Content.self, options: GenerationOptions = GenerationOptions(), contextOptions: ContextOptions = ContextOptions(includeSchemaInPrompt: true), metadata: [String : any Sendable & Codable & Equatable] = [:], @PromptBuilder prompt: () throws -> Prompt) async throws -> LanguageModelSession.Response<Content> where Content : Generable
```

## Parameters

- `type`: A type to produce as the response.
- `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

Return Value GeneratedContent containing the fields and values defined in the schema.

## Discussion

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.

## See Also

### Generating a response with metadata

- [respond(options:contextOptions:metadata:prompt:)](foundationmodels/languagemodelsession/respond(options:contextoptions:metadata:prompt:).md)
- [respond(schema:options:contextOptions:metadata:prompt:)](foundationmodels/languagemodelsession/respond(schema:options:contextoptions:metadata:prompt:).md)
- [respond(to:options:contextOptions:metadata:)](foundationmodels/languagemodelsession/respond(to:options:contextoptions:metadata:).md)
- [respond(to:generating:options:contextOptions:metadata:)](foundationmodels/languagemodelsession/respond(to:generating:options:contextoptions:metadata:).md)
- [respond(to:schema:options:contextOptions:metadata:)](foundationmodels/languagemodelsession/respond(to:schema:options:contextoptions:metadata:).md)
