Skip to main content

Add AI to a rich text editor in ASP.NET Core and keep keys on the server

The editor with the AI toolbar button

Rewriting, shortening and translating belong right where people write. But an AI key in the browser is a key anyone can copy. RichTextBox keeps the toolbar in the browser and the provider call on your ASP.NET Core server, behind an interface you control.

Turn it on

<richtextbox id="AiToolkitEditor"
             name="Body"
             toolbar="default"
             enable-ai-toolkit="true"
             ai-toolkit-persistence-key="article-42"
             height="440px"></richtextbox>

This gives you Ask AI on the toolbar, a docked chat panel, inline suggestions and a review drawer. The built-in demo resolver runs without a key, so you can try the whole flow first.

Connect a real provider

Implement the resolver and register it:

builder.Services.AddRichTextBox();
builder.Services.AddSingleton<IRichTextBoxAiResolver, MyAiResolver>();

Your resolver gets the request on the server, calls whichever provider you choose and returns the result. The browser only talks to your application, so the key stays in your configuration. The provider resolver demo has examples.

Keep control of it

People stay in charge

AI suggestions appear as a preview, and nothing changes until someone applies them. Suggestions are also recorded in the review ledger, next to tracked changes, so a reviewer can see what the AI proposed and what was accepted.

Saved HTML is still checked

Treat model output like anything else someone could type. Keep [RichTextHtml] on the property that receives the content.

Try it

The AI toolkit demo runs with no key, and the streaming demo shows words arriving as they are generated.

Read next