Skip to content

Why AI?

Calling an LLM API directly from a ProcessWire template takes ten lines of PHP. Turning that prototype into a safe, auditable, multi-language editorial and agent platform that respects ProcessWire templates, fields, permissions, and budgets is a completely different engineering problem.

Capability Ad-Hoc Provider SDK Scripts ProcessWire AI Module
Provider lock-in & failover Hardcoded to one vendor and one API key 10 ProviderDriver drivers with encrypted multi-key pools (failover / round_robin) and backup route chains
Secrets & SSRF safety Plaintext keys in DB; unvalidated custom endpoints SecretBox (enc:v1: / $env:) + EndpointUrlValidator + SsrfSafeCurlHttpClient
Hallucination & field safety Models overwrite arbitrary fields or invent facts MainRuleCatalog, FieldScopeMatcher, EditorialQualityValidator, and diff-preview ProposalApplier with rollback
Multi-language glossaries Translations break brand names and technical terms Protected ai-glossaries (Source => Target) + LanguageSupport localization + queued BulkTranslateQueue
Governance, PII & spend caps Unbounded token bills and accidental PII leaks 5 RBAC permissions, PiiScrubber, usage ledger (ai_usage_logs), monthly budget caps, and PruneAiUsageLogsTask
External AI clients (MCP) Custom REST scripts with no tool discovery Built-in JSON-RPC 2.0 (2024-11-05) McpServer over HTTP (/_ai/mcp) and stdio (ai:mcp) with pwai_* keys and RiskClass policies
Automated testing Flaky live API calls in CI First-class Ai::fake() with InMemoryVectorStore for deterministic, zero-network Pest tests

Because AI sits in the Entries-dependent domain layer, it integrates cleanly with sibling ProcessWire modules through isolated adapters (src/Integration/*) whenever they are installed:

  • Blocks: Composes schema-validated block trees and audits block content.
  • Seo: Optimizes meta titles, descriptions, and structured metadata without touching locked indexing flags.
  • Media: Generates accessible alt text, captions, focal points, and AI imagery directly in the media library.
  • Navigation: Localizes menu trees via Ai::localizeMenu.
  • Forms: Classifies incoming form submissions via Ai::classifySubmission.
  • Headless: Exposes /api/v1/ai/* and /api/v1/mcp endpoints automatically.

Next steps