The Tiny.AI add-on enhances Optimizely CMS 12 by seamlessly integrating OpenAI directly into the TinyMCE editor. It empowers editors to rewrite, improve, summarize, expand, or translate selected content without leaving the CMS. Instead of copying content into external AI tools and risking formatting issues, Tiny.AI processes HTML safely and returns clean, CMS-ready output.
Installation
The command below will install the add-on in your Optimizely project.
dotnet add package A2Z.Optimizely.Tiny.AI
Configuration
Add your OpenAI configuration inside appsettings.json. The model value below is an example and can be updated to a supported model that fits your setup.
{
"OpenAI": {
"ApiKey": "YOUR_API_KEY",
"Model": "gpt-4o-mini"
}
}
The module automatically registers required services, the API controller, and the TinyMCE plugin.
Service Registration
The package registers the OpenAI service, circuit breaker, and authorization services automatically through an initialization module.
[ModuleDependency(typeof(InitializationModule))]
public class AiInitialization : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.AddHttpClient<IOpenAiService, OpenAiService>();
context.Services.AddSingleton<EditorAuthorizationService>();
context.Services.AddSingleton<SimpleCircuitBreaker>();
}
}
Usage
Once installed and configured, editors will see a new AI Assistant button inside the TinyMCE toolbar.
How it works:
- Select content inside the TinyMCE editor.
- Click the AI Assistant button.
- Choose an action (Rewrite, Improve, Summarize, Expand, Translate).
- Optionally specify a language.
- Apply changes and the HTML is replaced instantly.
The AI processes the selected HTML and returns valid HTML only, preserving links and formatting.
Security
Access to Tiny.AI is restricted to users in the following roles:
- CmsEditors
- Administrators
Authorization is validated server-side to ensure only permitted users can invoke AI functionality.
Resilience & Performance
Tiny.AI is built for production environments and includes:
- Retry logic for transient API failures
- Exponential backoff for rate limiting (429 responses)
- Circuit breaker protection after repeated failures
- Structured logging for monitoring
- Token usage tracking
- Estimated cost calculation per request
If multiple consecutive failures occur, the circuit breaker temporarily disables AI calls to protect system stability.
Cost Transparency
Each request returns:
- Prompt tokens
- Completion tokens
- Total tokens
- Estimated cost
This provides visibility into AI usage and allows teams to monitor spending effectively.
API Endpoint
POST /api/editor/ai/action
Example request:
{
"action": "rewrite",
"html": "<p>Some content</p>",
"language": "en"
}
Example response:
{
"html": "<p>Rewritten content...</p>",
"tokens": 512,
"cost": 0.0003
}
Compatibility
Tiny.AI currently supports Optimizely CMS 12 only. Check the GitHub repository or package page for the latest updates and version support.
Why Tiny.AI?
AI is becoming an essential productivity tool for content teams. Tiny.AI integrates OpenAI directly into Optimizely CMS workflows while maintaining security, HTML integrity, and operational resilience.
It eliminates the need for external tools and keeps the editorial workflow fast, clean, and fully integrated.
You can access the code and documentation for Tiny.AI on its GitHub repository.
0 comments :
Post a Comment