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

# Image Generation Capability

Implement the experimental image-generation capability for your custom provider.

{% hint style="warning" %}
Image Generation is **experimental**. When the `Umbraco:AI:Experimental:ImageGeneration` feature flag is off, the capability is hidden from discovery and not selectable in the profile editor — even if a provider implements it.
{% endhint %}

The image-generation capability produces images from prompts. Implement it by extending `AIImageGeneratorCapabilityBase<TSettings>`.

## Base Class

{% code title="AIImageGeneratorCapabilityBase<TSettings>" %}

```csharp
public abstract class AIImageGeneratorCapabilityBase<TSettings>(IAIProvider provider)
    : AICapabilityBase<TSettings>(provider), IAICapability<TSettings>, IAIImageGeneratorCapability
    where TSettings : class
{
    public override AICapability Kind => AICapability.ImageGeneration;

    // Override this (or CreateGeneratorAsync) to create an IImageGenerator
    protected virtual IImageGenerator CreateGenerator(TSettings settings, string? modelId) { /* ... */ }

    // Override this for an async variant
    protected virtual Task<IImageGenerator> CreateGeneratorAsync(
        TSettings settings, string? modelId, CancellationToken cancellationToken = default) { /* ... */ }

    // Implement this: return available models (with constraint metadata)
    protected abstract Task<IReadOnlyList<AIModelDescriptor>> GetModelsAsync(
        TSettings settings,
        CancellationToken cancellationToken = default);
}
```

{% endcode %}

{% hint style="info" %}
`IImageGenerator` is marked `[Experimental("MEAI001")]` in Microsoft.Extensions.AI, and the Umbraco capability surface carries the `UMBRACOAI_IMAGEGEN` diagnostic. Add both `#pragma warning disable MEAI001` and `#pragma warning disable UMBRACOAI_IMAGEGEN` to your implementation files.
{% endhint %}

## Basic Implementation

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

```csharp
#pragma warning disable MEAI001
#pragma warning disable UMBRACOAI_IMAGEGEN

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

public class MyImageGenerationCapability : AIImageGeneratorCapabilityBase<MyProviderSettings>
{
    public MyImageGenerationCapability(IAIProvider provider) : base(provider) { }

    protected override IImageGenerator CreateGenerator(MyProviderSettings settings, string? modelId)
    {
        return new MyImageGenerator(settings, modelId ?? "default-image-model");
    }

    protected override Task<IReadOnlyList<AIModelDescriptor>> GetModelsAsync(
        MyProviderSettings settings,
        CancellationToken cancellationToken = default)
    {
        var models = new List<AIModelDescriptor>
        {
            new(
                new AIModelRef(Provider.Id, "image-standard"),
                "Standard Image Model",
                new Dictionary<string, string>
                {
                    ["image.supportedSizes"] = "1024x1024",
                    ["image.maxEdge"] = "1024",
                    ["image.supportsEdit"] = "false",
                    ["image.supportsMask"] = "false",
                })
        };
        return Task.FromResult<IReadOnlyList<AIModelDescriptor>>(models);
    }
}
```

{% endcode %}

{% hint style="info" %}
Surface per-model constraints via `AIModelDescriptor` metadata (`image.supportedSizes`, `image.maxEdge`, `image.supportsEdit`, `image.supportsMask`). Consumers read these through `GetSupportedModelsAsync` to validate requests before calling.
{% endhint %}

## Register in Provider

Add the image-generation capability in your provider constructor:

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

```csharp
[AIProvider("myprovider", "My AI Provider")]
public class MyProvider : AIProviderBase<MyProviderSettings>
{
    public MyProvider(IAIProviderInfrastructure infrastructure)
        : base(infrastructure)
    {
        WithCapability<MyChatCapability>();
        WithCapability<MyImageGenerationCapability>();  // Add image-generation support
    }
}
```

{% endcode %}

## Exposing a provider-native client (optional)

To let consumers reach your provider's native client for masked outpainting (Tier 3), return an `IImageGenerator` that overrides `GetService` to resolve that client. The OpenAI provider does this with `OpenAIClient`: wrap the `Microsoft.Extensions.AI` adapter in a `DelegatingImageGenerator` and return your native client for its type in `GetService`.

## Related

* [Creating a Provider](/ai-in-umbraco/19.latest/extending/providers/creating-a-provider.md) - Provider setup
* [Chat Capability](/ai-in-umbraco/19.latest/extending/providers/chat-capability.md) - Chat capability implementation
* [Speech-to-Text Capability](/ai-in-umbraco/19.latest/extending/providers/speech-to-text-capability.md) - Speech-to-text capability implementation
* [Image Generation API](/ai-in-umbraco/19.latest/using-the-api/image-generation.md) - Using the Image Generation API


---

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