---
title: ChatFeature Configuration
---
Every AI Chat capability is configured from a single `ChatFeature` plugin registration. Extension-specific options are reached through the extension properties it exposes (`Tools`, `ApiTools`, `Mcp`, `ShareStatic`, `ShareLlmspy`, `Pdf`, …), so a complete configuration reads as one object graph.
```csharp
services.AddPlugin(new ChatFeature {
RequireAuth = true,
RequiredRole = "Employee",
AuthType = ChatAuthType.Credentials,
DisableExtensions = ["computer", "share_llmspy"],
Tools = {
EnableApiTools = true,
EnableFilesystemTools = false,
EnableCodeExecution = false,
},
ApiTools = {
IncludeTags = ["CoffeeShop", "Bookings"],
},
Mcp = {
ToolGroups = ["api_tools"],
},
Setup = ctx => {
// runs after config + providers are created, before extensions install
},
});
```
## Hosting
| Property | Default | Description |
| --- | --- | --- |
| `RoutePrefix` | `"/chat"` | Path the Chat UI + APIs are mounted at. `""` mounts at the site root |
| `RequireAuth` | `true` | When false everything runs as the `"default"` user without authentication |
| `RequiredRole` | `null` | Only users in this role can access the Chat UI + APIs |
| `AuthType` | `Credentials` | How the UI signs users in - see [Integrated Auth](/chat/auth) |
| `SignInUrl` | `"/Account/Login"` | Identity login page the UI redirects to when `AuthType = OAuth` |
| `AppDataPath` | `~/App_Data/chat` | Root of AI Chat's file storage |
| `AutoInitSchema` | `true` | Create the OrmLite tables on startup |
| `NamedConnection` | `null` | Use a named OrmLite connection for chat data instead of the default |
| `DisableAdminUi` | `false` | Removes the `/admin-ui/chat` Admin UI and its APIs |
| `IncludeInGeneratedDtos` | `false` | Include `ServiceStack.AI` APIs and supporting types in generated client DTOs |
| `SvgIcon` | AI Chat icon | Icon used for the Admin UI link |
### Mounting at the site root
`RoutePrefix = ""` gives full [llms.py](https://llmspy.org) fidelity, serving the Chat UI from `/` - appropriate for a dedicated AI host rather than an App with its own pages:
```csharp
services.AddPlugin(new ChatFeature { RoutePrefix = "" });
```
## Extensions
| Property | Default | Description |
| --- | --- | --- |
| `DisableExtensions` | `[]` | Extension names to remove entirely, from server **and** UI |
| `Extensions` | built-ins | The extension list itself - add your own or reorder |
| `InstalledExtensionNames` | - | Read-only list of what actually installed |
```csharp
services.AddPlugin(new ChatFeature {
// remove the filesystem + run_bash tools completely
DisableExtensions = ["computer"],
// add your App's own extension
Extensions = {
new BookingToolsExtension(),
},
});
```
`disable_extensions` in `llms.json` is merged with `DisableExtensions`, so extensions can also be turned off without a redeploy. See [Extensions](/chat/extensions).
### Configuring your own extensions
An extension's configuration is just its own properties, so your extensions are configured **where they're added** - the same object-initializer syntax the built-ins use, one level deeper:
```csharp
services.AddPlugin(new ChatFeature {
Extensions = {
new BookingToolsExtension {
NamedConnection = "reporting",
DefaultTake = 50,
IncludeCancelled = false,
},
},
});
```
Those values are set before `Install(ctx)` runs, so an extension can read its own configuration while registering its routes and tools:
```csharp
public class BookingToolsExtension() : ChatExtension("booking_tools")
{
/// OrmLite connection bookings are read from
public string? NamedConnection { get; set; }
/// Rows returned when the Agent doesn't specify a limit
public int DefaultTake { get; set; } = 25;
/// Whether cancelled bookings are counted in summaries
public bool IncludeCancelled { get; set; }
public override void Install(ExtensionContext ctx)
{
if (NamedConnection != null)
ctx.Log.LogInformation("Bookings using {Db}", NamedConnection);
ctx.RegisterTool("bookings");
}
}
```
Configuration that has to see the fully-loaded feature belongs in `Setup` instead, which runs after config and providers load but before extensions install:
```csharp
services.AddPlugin(new ChatFeature {
Extensions = { new BookingToolsExtension() },
Setup = ctx => {
ctx.AssertExtension().DefaultTake = ctx.ApiTools.DefaultTake;
},
});
```
See [Custom Extensions](/chat/custom-extensions) for the full `ExtensionContext` API.
## Providers & config
| Property | Default | Description |
| --- | --- | --- |
| `Config` | seeded `llms.json` | The parsed `llms.json` document |
| `ConfigJson` | - | Write-only setter that parses a JSON string into `Config` |
| `ProviderModels` | seeded `providers.json` | The models.dev model catalog |
| `PreserveConfigs` | `[]` | Bundled config files in `App_Data/chat` to keep instead of overwriting on startup |
| `EnableProviders` | `[]` | Force-enable **only** these providers, overriding `llms.json` |
| `Variables` | `[]` | `$VAR` substitutions checked **before** environment variables |
| `ProviderTypes` | built-ins | npm sdk id → provider factory |
| `Providers` | - | The live (enabled + configured) providers |
| `LoadingMessages` | `["Computing", …]` | Words shown while a response streams |
### Preserving modified configs
`llms.json` is seeded only when missing and preserves user settings across restarts. Provider
catalogs (`providers.json` and `providers-extra.json`) refresh from bundled defaults on startup unless
their filenames are listed in `PreserveConfigs`. Preserved catalog files are seeded when missing.
```csharp
services.AddPlugin(new ChatFeature {
PreserveConfigs = ["providers-extra.json"],
});
```
Preserved files no longer pick up upstream changes, so when you preserve `providers.json` you're responsible for keeping it current, e.g. with [Update Provider Models](#update-provider-models) below.
### Update Provider Models
Each ServiceStack release includes the latest `providers.json`. To update the provider catalog between releases, override it with the latest version from the [ServiceStack/llms](https://raw.githubusercontent.com/ServiceStack/llms/refs/heads/main/llms/providers.json) repo.
Run the following command from your application's `App_Data/chat` directory to download and overwrite `providers.json`:
curl -fL https://raw.githubusercontent.com/ServiceStack/llms/refs/heads/main/llms/providers.json -o providers.json
Add `"providers.json"` to [PreserveConfigs](#preserving-modified-configs) so the downloaded catalog isn't replaced by the bundled copy on the next restart.
See [Providers & Models](/chat/providers).
## Limits
`Limits` mirrors the `limits` object in `llms.json`:
| Property | Default | Description |
| --- | --- | --- |
| `ClientTimeout` | `120` (`240` in llms.json) | Seconds before a provider request is abandoned |
| `ClientMaxSize` | `20 MB` | Largest response body accepted from a provider |
| `Retries` | `3` | Provider retry attempts before failing over |
| `MaxIterations` | `10` | Maximum tool-call rounds in one completion |
| `StreamCheckpointInterval` | `250ms` | How often an in-flight streamed response is persisted |
```csharp
services.AddPlugin(new ChatFeature {
Limits = {
MaxIterations = 20,
StreamCheckpointInterval = TimeSpan.FromMilliseconds(500),
},
});
```
`MaxIterations` is the ceiling on an agentic loop: a Model that keeps calling tools stops after this many rounds. Raise it for long multi-step workflows, lower it to bound cost.
## Request hooks
| Property | Description |
| --- | --- |
| `ValidateRequest` | `Func>` run before every Chat UI + API request. Return an `IHttpResult` to reject |
| `ValidateDownloadUrl` | `Action` called before downloading a URL referenced in a chat message |
| `UserNamesResolver` | Extra usernames offered in the Admin analytics user filter |
| `Setup` | `Action` run after config + providers load, before extensions install |
| `ImageTransformer` | `(bytes, width, height) => webp` hook used for upload downscaling and `?variant=` thumbnails |
```csharp
services.AddPlugin(new ChatFeature {
ValidateRequest = async req => {
if (req.GetSession() is { } session && await IsOverQuotaAsync(session.UserAuthId))
return HttpError.Forbidden("Monthly AI quota exceeded");
return null;
},
// populate the Admin analytics user filter from the App's Identity users
UserNamesResolver = req => req.Resolve().Open()
.Column(db.From().Select(x => x.UserName)),
});
```
`Setup` is the escape hatch for configuration that has to see the fully-loaded feature:
```csharp
Setup = ctx => {
ctx.Mcp.ToolGroups = ["api_tools", "core_tools", "booking_tools"];
ctx.Tools.ToolTimeout = TimeSpan.FromSeconds(120);
}
```
## Tool sandboxing
```csharp
Tools = {
EnableFilesystemTools = true,
AllowedDirectories = ["/srv/workspaces"],
}
```
Higher-risk capabilities are opt-in. Filesystem and code execution tools stay unregistered unless the host turns them on - and even then, [Projects](/chat/projects) further narrows each user's reachable directories. See [Tools](/chat/tools).
## AI Chat and the OpenAI API
`ChatFeature` also registers the typed `ChatCompletion` service at `POST /v1/chat/completions` and an in-process `IChatClient`. Both run the same pipeline - provider selection, retry/failover, the tool loop, usage and cost accounting. See [Chat API](/chat/api). `IChatClient.CreateDecisionAsync` and `POST /v1/decisions` also ask typed questions of decision models like Jev via OpenRouter. See [Decisions API](/chat/api#decisions-api).
### Generated client DTOs
AI Chat clients typically use its OpenAI-compatible API directly, so `ChatFeature` excludes its
`ServiceStack.AI` APIs and supporting types from generated [ServiceStack client DTOs](/add-servicestack-reference)
by default. The APIs remain registered and callable; this only keeps AI Chat's large contract from being
added to Apps which don't consume it through a generated ServiceStack client.
Opt in when your App needs strongly typed AI Chat DTOs:
```csharp
services.AddPlugin(new ChatFeature {
IncludeInGeneratedDtos = true,
});
```
## Sharing destinations
`ShareStatic` is enabled by default and publishes project builds to `/p`, typically
`wwwroot/p`. `ShareLlmspy` is disabled by default; set `ShareLlmspy.Enabled = true` to opt into public
hosting on ai.llmspy.org. Each extension can be disabled independently.
Use a typed code override for the static export settings:
```csharp
services.AddPlugin(new ChatFeature {
ShareStatic = {
StaticPublish = new StaticPublishConfig {
// Omit Directory to use the host's web content directory/p.
BasePath = "/p/",
BaseUrl = "", // Project links use the current browser origin.
},
},
});
```
Without the code override, settings load from `App_Data/chat/user/default/share_static/config.json`.
The file is optional; omit `directory` for the web-root default. Explicit relative directories resolve
from the working directory where the host starts. These are global settings, independent of named-user
and publisher account configuration. A code override replaces the file configuration, with defaults
for omitted properties.
An empty or null `BaseUrl` produces a link on the Chat UI's current domain using `BasePath`, independent
of `RoutePrefix`. A configured HTTP(S) URL includes its static mount path and overrides `BasePath`.
See [Publishing](/chat/publishing#configure-the-export) for JSON settings, static-file middleware order,
and serving a custom destination.
## Full configuration reference
```csharp
services.AddPlugin(new ChatFeature {
// ── Hosting ──
RoutePrefix = "/chat",
RequireAuth = true,
RequiredRole = null,
AuthType = ChatAuthType.Credentials,
SignInUrl = "/Account/Login",
AppDataPath = null, // ~/App_Data/chat
AutoInitSchema = true,
NamedConnection = null,
DisableAdminUi = false,
IncludeInGeneratedDtos = false,
// ── Extensions ──
DisableExtensions = [],
Extensions = { /* built-ins + your own */ },
// ── Providers ──
EnableProviders = [],
Variables = {},
PreserveConfigs = [], // e.g. ["llms.json", "providers.json"]
LoadingMessages = ["Computing", "Cooking", "Crafting", "Creating"],
// ── Limits ──
Limits = {
ClientTimeout = 120,
ClientMaxSize = 20 * 1024 * 1024,
Retries = 3,
MaxIterations = 10,
StreamCheckpointInterval = TimeSpan.FromMilliseconds(250),
},
// ── Extension config ──
Tools = { EnableApiTools = true, EnableFilesystemTools = false, EnableCodeExecution = false },
ApiTools = { IncludeTags = [], IncludeTypes = [], ExcludeTypes = [], DefaultTake = 25, MaxTake = 100 },
Mcp = { ToolGroups = [], Tools = [], RejectToolsRequiringApproval = true },
ShareStatic = { Enabled = true },
ShareLlmspy = { Enabled = false },
// ── Hooks ──
ValidateRequest = null,
ValidateDownloadUrl = null,
UserNamesResolver = null,
ImageTransformer = null,
Setup = null,
});
```