---
title: Generable
framework: foundationmodels
role: symbol
role_heading: Protocol
path: foundationmodels/generable
---

# Generable

A type that the model uses when responding to prompts.

## Declaration

```swift
protocol Generable : ConvertibleFromGeneratedContent, ConvertibleToGeneratedContent
```

## Mentioned in

Analyzing the runtime performance of your Foundation Models app Prompting an on-device foundation model Analyzing images with multimodal prompting Categorizing and organizing data with content tags Generating Swift data structures with guided generation Managing the context window

## Overview

Overview Annotate your Swift structure or enumeration with the @Generable macro to allow the model to respond to prompts by generating an instance of your type. Use the @Guide macro to provide natural language descriptions of your properties, and programmatically control the values that the model can generate. @Generable struct SearchSuggestions {     @Guide(description: "A list of suggested search terms.", .count(4))     var searchTerms: [SearchTerm]     @Generable     struct SearchTerm {         // Use a generation identifier for data structures the framework generates.         var id: GenerationID         @Guide(description: "A two- or three- word search term, like 'Beautiful sunsets'.")         var searchTerm: String     } } For every Generable type in a request, the framework converts its type and format information to a JSON schema and provides it to the model. This contributes to the available context window size. If the LanguageModelSession exceeds the available context size, it throws LanguageModelError.contextSizeExceeded(_:). To reduce the size of your generable type: Reduce the complexity of your Generable type by evaluating whether properties are necessary to complete the task. Give your properties short and clear names. Use Guide(description:) on properties only when it improves response quality. Add a Guide(description:_:) with maximumCount(_:) to reduce token usage. If the Generable type includes properties with clear names the model may have all it needs to generate your type, eliminating the need of Guide(description:). For more information on managing the context window size, see Managing the context window.

## Topics

### Creating a Generable type

- [Generable(description:)](foundationmodels/generable(description:).md)
- [Generable(description:representNilExplicitlyInGeneratedContent:)](foundationmodels/generable(description:representnilexplicitlyingeneratedcontent:).md)
- [Generable(name:description:representNilExplicitlyInGeneratedContent:)](foundationmodels/generable(name:description:representnilexplicitlyingeneratedcontent:).md)

### Creating a guide

- [Guide(description:)](foundationmodels/guide(description:).md)
- [Guide(description:_:)](foundationmodels/guide(description:_:).md)
- [GenerationGuide](foundationmodels/generationguide.md)

### Getting the schema

- [generationSchema](foundationmodels/generable/generationschema.md)

### Converting to partially generated

- [asPartiallyGenerated()](foundationmodels/generable/aspartiallygenerated().md)
- [PartiallyGenerated](foundationmodels/generable/partiallygenerated.md)

## Relationships

### Inherits From

- [ConvertibleFromGeneratedContent](foundationmodels/convertiblefromgeneratedcontent.md)
- [ConvertibleToGeneratedContent](foundationmodels/convertibletogeneratedcontent.md)
- [InstructionsRepresentable](foundationmodels/instructionsrepresentable.md)
- [PromptRepresentable](foundationmodels/promptrepresentable.md)
- [SendableMetatype](swift/sendablemetatype.md)

### Conforming Types

- [GeneratedContent](foundationmodels/generatedcontent.md)
- [ImageReference](foundationmodels/imagereference.md)

## See Also

### Structured output

- [Generating Swift data structures with guided generation](foundationmodels/generating-swift-data-structures-with-guided-generation.md)
- [GenerationSchema](foundationmodels/generationschema.md)
- [DynamicGenerationSchema](foundationmodels/dynamicgenerationschema.md)
- [GeneratedContent](foundationmodels/generatedcontent.md)
- [ConvertibleToGeneratedContent](foundationmodels/convertibletogeneratedcontent.md)
- [ConvertibleFromGeneratedContent](foundationmodels/convertiblefromgeneratedcontent.md)
