---
title: GenerationOptions.ToolCallingMode
framework: foundationmodels
role: symbol
role_heading: Structure
path: foundationmodels/generationoptions/toolcallingmode-swift.struct
---

# GenerationOptions.ToolCallingMode

A value you use to describe the model behavior when it comes to tool usage.

## Declaration

```swift
struct ToolCallingMode
```

## Mentioned in

Expanding generation with tool calling

## Overview

Overview Use this to control how the model interacts with tools for a given request. Tool calling mode supports three modes: The following changes the mode from required to allowed after the first tool call, which lets the model produce a final response: extension SessionPropertyValues {     @SessionPropertyEntry     var toolCallCount: Int = 0 }

struct RecipeDynamicProfile: LanguageModelSession.DynamicProfile {     @SessionProperty(\.toolCallCount)     var toolCallCount     var body: some LanguageModelSession.DynamicProfile {         Profile {             BreadDatabaseTool()         }         .toolCallingMode(toolCallCount < 1 ? .required : .allowed)         .onToolCall {             toolCallCount += 1         }     } } important: When you set the mode to required, you must define an exit condition by either throwing an error from a tool’s call(arguments:) method or by changing the mode dynamically using a LanguageModelSession.DynamicProfile; otherwise, the model continues to call the tool.

## Topics

### Getting the tool calling modes

- [allowed](foundationmodels/generationoptions/toolcallingmode-swift.struct/allowed.md)
- [disallowed](foundationmodels/generationoptions/toolcallingmode-swift.struct/disallowed.md)
- [required](foundationmodels/generationoptions/toolcallingmode-swift.struct/required.md)

### Accessing the content

- [kind](foundationmodels/generationoptions/toolcallingmode-swift.struct/kind-swift.property.md)
- [GenerationOptions.ToolCallingMode.Kind](foundationmodels/generationoptions/toolcallingmode-swift.struct/kind-swift.enum.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Configuring options

- [temperature](foundationmodels/generationoptions/temperature.md)
- [sampling](foundationmodels/generationoptions/sampling.md)
- [samplingMode](foundationmodels/generationoptions/samplingmode-swift.property.md)
- [GenerationOptions.SamplingMode](foundationmodels/generationoptions/samplingmode-swift.struct.md)
- [toolCallingMode](foundationmodels/generationoptions/toolcallingmode-swift.property.md)
- [maximumResponseTokens](foundationmodels/generationoptions/maximumresponsetokens.md)
