Server configuration
The server configuration holds the licence key for the AI endpoint and the connection to your AI provider. The editor itself is configured with Editor options; without AI you need no server configuration at all, only HtmlSanitizer.
Where the configuration lives
veditor_config() (functions.php, loaded by autoload.php and by the Composer autoloader) reads:
- the file named by the
VEDITOR_CONFIGconstant or environment variable, - otherwise
config.phpin the package directory, - otherwise the template
config.dist.php.
A VEDITOR_CONFIG that points to a missing file throws RuntimeException (“VEDITOR_CONFIG: configuration file not found”). The configuration is read once per request.
With Composer, keep the file outside vendor/ (a Composer update replaces the package directory) and point VEDITOR_CONFIG to it. The Laravel, Symfony and Yii2 integrations take the same keys from their own configuration.
<?php
// config/veditor.php in your project
$config = require __DIR__ . '/../vendor/veditor/veditor/config.dist.php';
$config['aiContext'] = 'We write in British English. Our product is called Acme Shop.';
return $config;
Without Composer
The release ZIP has config.dist.php next to functions.php. Copy it to config.php in the same directory (for example veditor/config.php) and edit the copy: veditor_config() reads it without any other setting. The ZIP contains no config.php, so unpacking a new version over the directory keeps your file; if you replace the whole directory on update, copy the file back. If the package directory is reachable from the browser, keep the file outside it and point VEDITOR_CONFIG to it instead.
cp veditor/config.dist.php veditor/config.php
Setting VEDITOR_CONFIG
veditor_config() looks for the VEDITOR_CONFIG constant first and then for the environment variable, read with getenv(). It does so on its first call and keeps the result for the request, so set the value before that call, for example before require of autoload.php. The constant wins over the environment variable.
// in PHP: a constant…
define('VEDITOR_CONFIG', '/var/www/app/config/veditor.php');
// …or an environment variable of the process
putenv('VEDITOR_CONFIG=/var/www/app/config/veditor.php');
require __DIR__ . '/veditor/autoload.php';
# Apache: the virtual host, or .htaccess with AllowOverride FileInfo (mod_env)
SetEnv VEDITOR_CONFIG /var/www/app/config/veditor.php
; PHP-FPM: the pool configuration (for example pool.d/www.conf); reload PHP-FPM afterwards
env[VEDITOR_CONFIG] = /var/www/app/config/veditor.php
Apache and PHP-FPM settings apply to web requests only; command-line scripts need the variable in their own environment or the constant.
Keys
| Key | Description |
|---|---|
licenseKey | licence key (by default from the VEDITOR_LICENSE_KEY environment variable) |
aiTextModel | model; it also selects the provider: claude-… = Anthropic (Claude, Messages API), any other = OpenAI (Responses API); empty = OpenAI gpt-6.1-terra; required for openai-compatible. See Supported AI models |
aiApiKey | OpenAI API key, also used for openai-compatible (by default from OPENAI_API_KEY); never a Claude key |
aiAnthropicKey | Anthropic (Claude) API key for claude-… models (by default from ANTHROPIC_API_KEY) |
aiEndpoint | OpenAI or openai-compatible API address, for example a company proxy; empty = https://api.openai.com/v1, required for openai-compatible |
aiAnthropicEndpoint | Anthropic API address, for example a company proxy; empty = https://api.anthropic.com/v1 |
aiProvider | needed only for openai-compatible (Chat Completions: Azure OpenAI, Mistral, Ollama, vLLM…); the default openai means the provider follows from the model (anthropic still works for backward compatibility) |
aiTimeout | time limit of one AI request in seconds (default 60) |
aiMaxRequest | maximum size of one AI request body in bytes (default 2,000,000) |
aiContext | brand context added to every request: style guide, preferred terms, company description (up to 6000 characters) |
aiActions | your own AI actions: [['id' => 'seo', 'label' => 'Make it SEO friendly', 'prompt' => '…']] |
aiFeatures | AI functions for the current user (null = all): transform, prompt, translate, presets, chat, review, describeImage, metadata, complete |
aiBeforeRequest | hook before every paid request: fn(string $feature, array $data) returning true, a message or false |
Providers
// Anthropic (Claude): the model selects the provider
$config['aiTextModel'] = 'claude-sonnet-5-5';
$config['aiAnthropicKey'] = getenv('ANTHROPIC_API_KEY') ?: '';
// Ollama on the same server
$config['aiProvider'] = 'openai-compatible';
$config['aiEndpoint'] = 'http://localhost:11434/v1';
$config['aiTextModel'] = 'llama3.1';
$config['aiApiKey'] = 'ollama';
You need only the key of the provider of the chosen model; without it the editor shows no AI buttons. A Claude model uses aiAnthropicKey and aiAnthropicEndpoint, never aiApiKey or aiEndpoint. An unknown aiProvider returns HTTP 500 and writes the reason to the PHP error log.
Per-user features and limits
aiFeatures and aiBeforeRequest are read on every request, so set them from the logged-in user before you call AiApi:
$config = veditor_config();
$config['aiFeatures'] = $user->isAdmin() ? null : ['transform', 'review'];
$config['aiBeforeRequest'] = function (string $feature, array $data) use ($user) {
return $user->aiRequestsToday() < 200 ? true : 'Daily AI limit reached.';
};
A refused feature returns HTTP 403, a refusal from the hook HTTP 429 with your message (false gives the standard “The AI usage limit has been reached. Try again later.”). The hook runs only before paid requests and gets the feature name: transform, prompt (your own prompt), translate, presets (your aiActions), chat, review, describeImage, metadata or complete. The editor hides features the user may not use (config action) and the server checks every request again.
Next steps
Something unclear? Send feedback on the documentation.