Contents

AI

The AI edition adds an AI assistant, an AI chat, a text review, autocomplete, alt text and texts for publishing. AI functions run through your own endpoint on your own API key with OpenAI, Anthropic or an OpenAI-compatible service. The API key never reaches the browser, and the vendor is not involved in AI requests or payments.

How it works

  1. The editor sends { action, data } to your endpoint (ai.url) with the CSRF token in the X-CSRF-Token header.
  2. Your endpoint checks that the user may edit content and passes the request to VEditor\AiApi.
  3. AiApi checks POST, the CSRF token, the request size, the licence (AI edition) and the features allowed for the user, then calls the provider through AiClient.
  4. HTML from the model is sanitized on the server and again by the editor schema before the preview.

Prompts live only on the server (VEditor\AiActions). The browser sends the content, the action name, a tone and a language from whitelists and the user’s own prompt, which goes into the model input, never into the instructions.

Endpoint

The Laravel, Symfony and Yii2 integrations include the endpoint. Without a framework see PHP without a framework. In the editor:

await VEditor.create('#content', {
    ai: { url: '/veditor/ai', csrfToken: token, autocomplete: false },
});

If the editor cannot load the AI settings from ai.url (wrong address, server error), the AI buttons stay hidden and the browser console shows “AI settings could not be loaded.” The AI buttons appear only when ai.url is set and the licence covers the AI edition (on local and test addresses: a trial key or an AI edition key).

Supported AI models

The model name (aiTextModel) selects the provider: a claude-… model uses Anthropic (Claude), any other model uses OpenAI. Without a model, VEditor uses OpenAI gpt-6.1-terra.

ProviderModelAPI keyAPI address
OpenAI (default)gpt-6.1-terra or another non-Claude modelaiApiKey (OPENAI_API_KEY)aiEndpoint
Anthropic (Claude)claude-haiku-5-5, claude-sonnet-5-5, claude-opus-5-5aiAnthropicKey (ANTHROPIC_API_KEY)aiAnthropicEndpoint
OpenAI-compatible servicerequired, for example llama3.1aiApiKeyaiEndpoint (required)

You need only the key of the provider of the chosen model. Without it the editor shows no AI buttons. Never put a Claude key in aiApiKey. aiProvider is needed only for an OpenAI-compatible service (openai-compatible). The API address can point to a company proxy; empty means the provider’s default address.

Tested models: gpt-6.1-terra, claude-haiku-5-5, claude-sonnet-5-5 and claude-opus-5-5. Another model works, but VEditor writes a warning with the list of tested models to the PHP error log once. To have a model tested and added, send a request.

With Claude, simple tasks (alt text, SEO title and description, autocomplete) use low effort, which is faster and cheaper. The answer limit is at least 4,000 tokens, because the model’s thinking counts towards it; you pay only for the tokens the model generates.

Functions

FunctionWhat it does
AI assistantfor a selection: “Improve writing”, “Fix spelling and grammar”, “Make shorter”, “Make longer”, “Simplify”, “Continue writing”, “Change tone” (professional, casual, friendly, confident, empathetic, formal), “Translate”, or your own prompt in “Ask AI to write or edit…”; without a selection the same actions work on the current paragraph, and in an empty paragraph your prompt or “Continue writing” writes new text at the caret
Document translation“Whole document” → “Translate”: the whole content with its structure, preview in a window, “Replace document” or “Cancel”
Texts for publishingsummary (lead), SEO description, 3 title ideas, slug; copy or insert the summary at the top
Alt text“Describe (AI)” next to the alt text field in the image dialog
AI chata side panel conversation about the document and the selection; insert the answer, replace the selection or copy; nothing is stored
Text review“Check the text (AI)” in the review panel: spelling, grammar, punctuation, style, clarity and consistency, each remark highlighted with “Apply” and “Skip”
Autocompletewith ai.autocomplete: true, after a pause at the end of a paragraph (20+ characters) a grey suggestion of a few words; Tab accepts, Esc or typing rejects
Your actionsactions defined by the administrator (aiActions), with prompts on the server

Every result first goes to a preview. A changed selection or paragraph offers “Replace”, “Insert below”, “Try again” and “Discard”; new text at the caret offers “Insert”, “Try again” and “Discard”; a translated document offers “Replace document” and “Cancel”. Applying a result is one undo step. The assistant, the document translation and the chat are streamed: the text appears as the model writes; “Cancel” (before the first words) or “Stop” ends the assistant and the chat, and the × closes the translation window.

AI assistant preview of a shortened paragraph with Replace, Insert below, Try again and Discard
AI chat side panel with a question about the document and an answer with “Insert into the document” and “Copy”
Text review with AI remarks on spelling and grammar, each with Apply and Skip
Publishing texts dialog with a summary, an SEO description, three title ideas and a slug
Image dialog with alt text written by “Describe (AI)”
Grey autocomplete suggestion at the end of a paragraph with the hint Tab to accept, Esc to reject

Text review

“Check the text (AI)” sends the document to the model and lists its remarks under “Text” in the review panel. Each remark shows its type, the original fragment crossed out, the suggestion (“∅” when the suggestion removes the fragment) and, if the model gave one, an explanation. Pointing at a remark with the mouse or the keyboard highlights the fragment in the content without changing the document, and clicking the change scrolls to the fragment.

  • Apply replaces the fragment in the content with the suggestion as one undo step and removes the remark from the list. The fragment is looked up by its text (first with matching case, then ignoring case). If it is no longer in the text, for example because you edited it, “Apply” is disabled and the remark says “The fragment is no longer in the text.”
  • Skip removes the remark from the list without changing the content.

When every remark is handled, the panel shows “All suggestions handled.” “Check again” appears once a remark has been handled or when there are no remarks, and sends the current content again. Remarks are not stored: after closing and reopening the panel, the text check starts again from “Check the text (AI)”.

Editor options

OptionDefaultDescription
ai.urlnoneyour endpoint
ai.csrfTokennonesent in X-CSRF-Token
ai.headers{}extra headers
ai.languagesen, pl, de, fr, es, it, uk, cstranslation targets. Accepted codes: the 36 interface languages plus ru, ja, zh, ko, ar and no; regional codes such as pt-BR use the base language.
ai.languageeditor languagelanguage of alt text
ai.autocompletefalseautocomplete; every suggestion is a paid request
ai.autocompleteDelay900pause in milliseconds before a suggestion

For your application

const meta = await editor.aiTools.metadata();      // { summary, metaDescription, titles, slug }
document.querySelector('#seo-description').value = meta.metaDescription;

const alt = await editor.aiTools.describeImage('/uploads/photo.webp');
editor.on('aiMetadata', (meta) => { /* texts generated in the dialog */ });

Images and privacy

For alt text the browser scales the image down to 1024 px and sends it as JPEG; the server never fetches URLs. The image must come from the same domain or allow CORS. Content is sent to the provider only when a user starts an AI function; mention this in your privacy policy.

Costs and control

  • You pay the provider directly according to its pricing.
  • aiFeatures limits functions per user, aiBeforeRequest runs before every paid request (for example a daily limit), and aiContext adds your brand guidelines to every request. See Server configuration.
  • Errors from the provider are shown as short messages; details go to the PHP error log, never with the key.

Limits

WhatLimitWhen exceeded
request bodyaiMaxRequest, 2,000,000 bytes by defaultHTTP 413 “The request is too large.”
text for an action60,000 characters“The text is too long for the AI function.”
your own prompt2,000 charactersthe request is refused
document context sent with “Continue writing”, your own prompt and in an empty paragraph8,000 characters (for “Continue writing”: the text up to the paragraph or selection)shortened
text before the caret for autocompletethe last 3,000 charactersearlier text is not sent
aiContext6,000 charactersshortened
AI chata question up to 4,000 characters (the field limit); the last 20 messages; the first 55,000 characters of the document HTMLolder messages are not sent
image for alt text1.5 MB, data:image/jpeg, png or webp only“The image could not be read.”

Entries of aiActions need an id matching ^[a-z0-9_-]{1,40}$ and a non-empty label and prompt; the label is cut to 80 characters and the prompt to 4,000. Invalid entries are skipped without an error, and with a repeated id the last entry wins.

Endpoint protocol

You need this only for your own endpoint in another language; the PHP classes and the integrations implement it. The editor sends POST with JSON { "action": "…", "data": { … } } and the X-CSRF-Token header; streamed actions add "stream": true.

ActionPaidAnswer
statusno{ "ai": true, "version": "1.0.0" } (ai: the API key of the chosen model’s provider is configured)
configno{ "features": [...], "actions": [{ "id", "label" }] } for the current user
transform, chatyesJSON, or a stream with "stream": true
review, metadata, describeImage, completeyesJSON

Errors are JSON { "error": "…", "params": { … }, "stop": true }. error is an English message that the editor translates, params fills its {placeholders}, and stop: true means that trying again will not help (for example an invalid API key or no credit).

HTTPWhen
400unknown action, invalid data, or an error reported by the provider
403invalid CSRF token, no AI edition licence, or a function not allowed by aiFeatures
405not a POST request
413request body over aiMaxRequest
429refused by aiBeforeRequest
500server error, for example an unknown aiProvider (details in the PHP error log)

A stream is text/event-stream with lines data: {json}: first { "delta": "…" } with raw text, then { "done": true, "html": "…" } with the HTML sanitized on the server, or { "error": … }. The HTTP status of a stream is always 200; errors arrive as events.

Streaming behind a proxy

Streamed responses use text/event-stream. AiApi::sendStream() sends X-Accel-Buffering: no for nginx and disables mod_deflate on Apache with mod_php. If you put a CDN or another proxy in front, disable response buffering for the AI endpoint.

Something unclear? Send feedback on the documentation.