Skip to content

Settings

The submodule hard-depends on three contrib projects, none of which the root composer require pulls in — they are suggest-only so a styling-only site never carries the AI stack:

composer require drupal/ai drupal/ai_agents drupal/key
drush en canvas_builder_ai

Then, in order:

  1. Configure a provider in the AI module.
  2. Turn the feature on — canvas_builder_ai.settings: enabled ships as false, so the panel stays hidden until you enable it under Canvas Builder → AI.
  3. Approve the components the generator may use.
  4. Grant use canvas_builder ai to the roles that should see the panel.

Two operation types matter:

  • chat_with_tools — the section-create path, which uses native function calling. It must be a tools-capable model.
  • chat_with_structured_response — everything else.

Check your configured models are current

A provider default pointing at a retired model fails at invoke time with an error that does not obviously name the cause. If generation fails immediately and consistently, verify the model ids in the AI module's settings before looking anywhere else.

Stock photography (optional). Add an Unsplash or Pexels API key on the AI settings page to let builds place real imagery. Without one, sections are built without photographs rather than with invented urls.

Cost

Token usage is recorded per generation and surfaced on a usage dashboard, with per-model input/output pricing configurable in settings. A full-page build is one model call per section, not one call for the page.

AI usage dashboard: build stats, estimated time savings, total tokens in/out, total estimated cost, and a per-build log with tokens and est. cost per row

Configuration → Content authoring → Canvas Builder → Usage — every generation logged, filterable by action and date, with a per-model cost estimate.

Config keys without an admin form

The settings page covers the rest; these are drush config:set only:

Key Purpose Default
canvas_builder_ai.settings: generation.max_prompt_length Longest editor prompt accepted, in characters. 2000
canvas_builder_ai.settings: generation.http_timeout Provider HTTP timeout, in seconds. 60
canvas_builder_ai.settings: guardrails.max_slot_depth Deepest slot nesting a generated plan may use. 5
canvas_builder_ai.settings: pricing.models Per-model rate rows ({model, input, output, cached}) that win over the synced OpenRouter rates and pricing.default. { }
canvas_builder_ai.components: components.N.allowed_props / allowed_slots / workflows / capabilities Per-component allowlists; empty means everything. The components form carries them through unchanged. (absent)
drush config:set canvas_builder_ai.settings generation.http_timeout 120