> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/19.latest/reference/services/ai-settings-service.md).

# IAISettingsService

Service for managing global AI settings.

Service for reading and updating global AI settings such as default profiles.

## Namespace

```csharp
using Umbraco.AI.Core.Settings;
```

## Interface

{% code title="IAISettingsService" %}

```csharp
public interface IAISettingsService
{
    Task<AISettings> GetSettingsAsync(CancellationToken cancellationToken = default);

    Task<AISettings> SaveSettingsAsync(AISettings settings, CancellationToken cancellationToken = default);
}
```

{% endcode %}

## Methods

### GetSettingsAsync

Gets the current global AI settings.

| Parameter           | Type                | Description        |
| ------------------- | ------------------- | ------------------ |
| `cancellationToken` | `CancellationToken` | Cancellation token |

**Returns**: The current settings. Creates default settings if none exist.

{% code title="Example" %}

```csharp
var settings = await _settingsService.GetSettingsAsync();

if (settings.DefaultChatProfileId.HasValue)
{
    Console.WriteLine($"Default chat profile: {settings.DefaultChatProfileId}");
}
else
{
    Console.WriteLine("No default chat profile configured");
}
```

{% endcode %}

### SaveSettingsAsync

Updates the global AI settings.

| Parameter           | Type                | Description          |
| ------------------- | ------------------- | -------------------- |
| `settings`          | `AISettings`        | The settings to save |
| `cancellationToken` | `CancellationToken` | Cancellation token   |

**Returns**: The saved settings with audit properties updated.

{% code title="Example" %}

```csharp
var settings = await _settingsService.GetSettingsAsync();
settings.DefaultChatProfileId = chatProfileId;
settings.DefaultEmbeddingProfileId = embeddingProfileId;

var saved = await _settingsService.SaveSettingsAsync(settings);
Console.WriteLine($"Settings updated at {saved.DateModified}");
```

{% endcode %}

## Usage Example

{% code title="SettingsManager.cs" %}

```csharp
public class SettingsManager
{
    private readonly IAISettingsService _settingsService;
    private readonly IAIProfileService _profileService;

    public SettingsManager(
        IAISettingsService settingsService,
        IAIProfileService profileService)
    {
        _settingsService = settingsService;
        _profileService = profileService;
    }

    public async Task SetDefaultChatProfileAsync(string profileAlias)
    {
        var profile = await _profileService.GetProfileByAliasAsync(profileAlias);
        if (profile == null)
        {
            throw new ArgumentException($"Profile '{profileAlias}' not found");
        }

        if (profile.Capability != AICapability.Chat)
        {
            throw new ArgumentException($"Profile '{profileAlias}' is not a chat profile");
        }

        var settings = await _settingsService.GetSettingsAsync();
        settings.DefaultChatProfileId = profile.Id;
        await _settingsService.SaveSettingsAsync(settings);
    }

    public async Task ClearDefaultsAsync()
    {
        var settings = await _settingsService.GetSettingsAsync();
        settings.DefaultChatProfileId = null;
        settings.DefaultEmbeddingProfileId = null;
        await _settingsService.SaveSettingsAsync(settings);
    }
}
```

{% endcode %}

## Notes

* Settings use a singleton pattern - there is always exactly one settings record
* Settings are not versionable
* Settings are cached for performance; cache is invalidated on save

## Related

* [AISettings](/ai-in-umbraco/19.latest/reference/models/ai-settings.md) - The settings model
* [Settings Concept](/ai-in-umbraco/19.latest/concepts/settings.md) - Settings concepts


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/ai-in-umbraco/19.latest/reference/services/ai-settings-service.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
