> 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/extending/providers.md).

# Custom Providers

Create custom AI providers to support additional AI services.

Providers are plugins that connect Umbraco.AI to AI services. Create a custom provider to add support for AI services not included out of the box.

## Provider Architecture

A provider consists of:

1. **Provider class** - Main class with `[AIProvider]` attribute
2. **Settings class** - Configuration properties with `[AIField]` attributes
3. **Capability classes** - Implementations for Chat, Embedding, and so on

```
MyProvider/
├── MyProvider.cs              # Main provider class
├── MyProviderSettings.cs      # Settings with [AIField] attributes
├── MyChatCapability.cs        # Chat capability implementation
└── MyEmbeddingCapability.cs   # Embedding capability (optional)
```

## Quick Start

### 1. Create a Settings Class

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

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

public class MyProviderSettings
{
    [AIField(Label = "API Key", Description = "Your API key", IsSensitive = true)]
    public string? ApiKey { get; set; }

    [AIField(Label = "Endpoint", Description = "API endpoint URL")]
    public string? Endpoint { get; set; }
}
```

{% endcode %}

### 2. Create a Chat Capability

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

```csharp
using Microsoft.Extensions.AI;
using Umbraco.AI.Core.Models;
using Umbraco.AI.Core.Providers;

public class MyChatCapability : AIChatCapabilityBase<MyProviderSettings>
{
    public MyChatCapability(IAIProvider provider) : base(provider) { }

    protected override IChatClient CreateClient(MyProviderSettings settings, string? modelId)
    {
        // Create and return your IChatClient implementation
        return new MyChatClient(settings.ApiKey, settings.Endpoint, modelId);
    }

    protected override Task<IReadOnlyList<AIModelDescriptor>> GetModelsAsync(
        MyProviderSettings settings,
        CancellationToken cancellationToken = default)
    {
        // Return available models
        var models = new List<AIModelDescriptor>
        {
            new(new AIModelRef(Provider.Id, "my-model-1"), "My Model 1"),
            new(new AIModelRef(Provider.Id, "my-model-2"), "My Model 2")
        };
        return Task.FromResult<IReadOnlyList<AIModelDescriptor>>(models);
    }
}
```

{% endcode %}

### 3. Create the Provider Class

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

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

[AIProvider("myprovider", "My AI Provider")]
public class MyProvider : AIProviderBase<MyProviderSettings>
{
    public MyProvider(IAIProviderInfrastructure infrastructure)
        : base(infrastructure)
    {
        WithCapability<MyChatCapability>();
    }
}
```

{% endcode %}

## How It Works

1. Providers are discovered automatically via assembly scanning
2. The `[AIProvider]` attribute registers the provider with an ID and name
3. Settings are rendered in the backoffice using `[AIField]` metadata
4. Capabilities are registered in the constructor with `WithCapability<T>()`

## In This Section

{% content-ref url="/pages/ljbNl5I4uFNDCYLRQabm" %}
[Creating a Provider](/ai-in-umbraco/extending/providers/creating-a-provider.md)
{% endcontent-ref %}

{% content-ref url="/pages/7H0yYg9j6GVkmA2MMBbJ" %}
[Provider Settings](/ai-in-umbraco/extending/providers/provider-settings.md)
{% endcontent-ref %}

{% content-ref url="/pages/V2KSBvZTcIpa20gkfDdx" %}
[Chat Capability](/ai-in-umbraco/extending/providers/chat-capability.md)
{% endcontent-ref %}

{% content-ref url="/pages/P5ifg7rzgNhuMBpicrtR" %}
[Embedding Capability](/ai-in-umbraco/extending/providers/embedding-capability.md)
{% endcontent-ref %}


---

# 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/extending/providers.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.
