Download the PHP package xddesigners/silverstripe-ai without Composer
On this page you can find all versions of the php package xddesigners/silverstripe-ai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xddesigners/silverstripe-ai
More information about xddesigners/silverstripe-ai
Files in xddesigners/silverstripe-ai
Package silverstripe-ai
Short Description Core AI platform integration for Silverstripe using Symfony AI
License BSD-3-Clause
Informations about the package silverstripe-ai
silverstripe-ai
Core AI platform integration for SilverStripe, built on Symfony AI.
Provides a unified AIClient service and a /ai/generate endpoint that works with OpenAI, Anthropic,
Google (Gemini & Vertex AI), Azure OpenAI, Mistral, Ollama, OpenRouter, and any OpenAI-compatible endpoint.
Requirements
- SilverStripe Framework
^6 - PHP
^8.1
Installation
Configuration
Add the following to your .env file:
Supported platforms and models
| Platform type | Example models | Extra environment variables |
|---|---|---|
openai |
gpt-4o, gpt-4o-mini, gpt-3.5-turbo |
— |
anthropic (claude) |
claude-sonnet-4-6, claude-haiku-4-5 |
— |
gemini (google) |
gemini-2.0-flash, gemini-1.5-pro |
— |
azure |
your deployment name | AI_PLATFORM_BASE_URL (resource endpoint), AI_AZURE_DEPLOYMENT, AI_AZURE_API_VERSION (default 2024-10-21) |
vertex |
gemini-1.5-pro |
AI_VERTEX_LOCATION, AI_VERTEX_PROJECT (key optional; ADC supported) |
mistral |
mistral-large-latest, mistral-small-latest |
— (native bridge; AI_PLATFORM_BASE_URL only used for the generic fallback) |
ollama |
any locally pulled model | AI_PLATFORM_BASE_URL (optional; defaults to http://localhost:11434) |
openrouter |
any OpenRouter slug, e.g. anthropic/claude-sonnet-5 |
AI_PLATFORM_BASE_URL (optional; set to route in-region — see below) |
generic |
any model on the endpoint | AI_PLATFORM_BASE_URL (required) — any OpenAI-compatible endpoint |
mistral uses the native Symfony Mistral bridge (bundled), falling back to Mistral's OpenAI-compatible EU
endpoint if that package is removed. ollama and generic reach their providers through the OpenAI-compatible
generic bridge, so no extra package is needed.
EU data residency
Keep inference inside the EU by pointing an OpenAI-compatible platform at an in-region endpoint via
AI_PLATFORM_BASE_URL:
Other EU-friendly options: mistral (Mistral’s EU platform, the default endpoint), azure in an EU region,
or ollama/generic against a model you host in the EU — data then never leaves your infrastructure.
Optional YAML configuration
You can override AIClient defaults in YAML:
Usage
In PHP
Inject or instantiate AIClient and call one of its two methods:
Via the HTTP endpoint
The module registers a /ai/generate route that accepts POST requests.
Text mode
Response:
Fields mode
Response:
Error responses
| Status | Meaning |
|---|---|
400 |
Missing or invalid input |
429 |
Rate limit exceeded (includes retry_after_seconds) |
500 |
AI generation failed |
Usage logging & the AI Usage admin
Every request is logged to AIRequestLog (platform, model, mode, token counts and estimated cost) and can be browsed under the AI Usage CMS section.
Token usage is captured for every supported provider. Native bridges (OpenAI, Anthropic, Gemini, Vertex AI, Mistral) report it through Symfony AI's
token_usagemetadata; for OpenAI-compatible endpoints that don't surface that metadata (OpenRouter, Ollama, the generic bridge) the counts are read from the response'susageblock as a fallback. Cost is only estimated when the model is listed inmodel_pricing(see below) — otherwise the request is logged with token counts but no cost.
Who can see it
- Administrators always have access.
- Grant other groups access by ticking “Access to 'AI Usage' section” under Security → Groups → Permissions. Unlike most CMS sections, holding “Access to all CMS sections” does not reveal it.
Hiding it from clients
Set this in .env to hide the section entirely (menu + access), for everyone including admins:
Currency (default USD)
The summary and the per-row cost show the estimate in USD by default, because provider pricing is in USD. To display another currency, set the symbol and an optional USD→currency rate — the stored value stays USD; the rate only affects display:
The figure remains an estimate, so set currency_rate to whatever approximate rate you want reflected.
Privacy & data processing
This module sends the text you pass to AIClient — page content, field values, prompts — to the third-party
AI provider you configure. Treat that as a data-processing step:
- Personal data / GDPR: if that content can contain personal data, the AI provider acts as a processor.
Choose the provider and region accordingly, record it in your processing register, and cover it in your
privacy policy / DPA. For EU data residency, route through an in-region endpoint (see EU data residency
above) — e.g. OpenRouter's
eu.openrouter.ai, Mistral's EU platform, Azure in an EU region, or a self-hosted model. - What is logged:
AIRequestLogstores only metadata (platform, model, token counts, estimated cost and the requesting CMS member) — never the prompt or the response. Enabling the AI Usage admin does not create a store of processed content. - Endpoint trust: your
AI_API_KEYis sent as a bearer token toAI_PLATFORM_BASE_URL(for theopenrouter/generic/mistral/ollamatypes). Point it only at endpoints you trust. - Access & hardening:
/ai/generaterequires a logged-in CMS user (CMS_ACCESS), is POST-only, CSRF-protected and per-member rate limited. Do not run the site in dev mode in production — dev mode returns raw error detail to the client.
Extending: custom platforms & models
Extra models need no code. Set AI_MODEL to any model your platform supports, and (for cost estimates) add its rate under model_pricing — see Optional YAML configuration.
Extra platforms / providers are added in code via the updatePlatform extension hook on AIClient. A "platform" is any Symfony AI PlatformInterface — a bundled bridge factory or your own implementation. Return one from the hook to add a new AI_PLATFORM_TYPE, or to override a built-in one. Token usage, cost estimation and request logging are handled by AIClient for any platform, so nothing else is required.
Then set AI_PLATFORM_TYPE="myprovider" (plus AI_MODEL, and optional model_pricing). For a fully custom provider, implement Symfony AI's PlatformInterface yourself — see the Symfony AI platform docs.
Extending the controller
By default the endpoint is POST-only and AIController::assertAccess() requires a logged-in member (returning Security::permissionFailure() otherwise). Subclass the controller to add your own permission logic — return an HTTPResponse to deny, or null to allow:
Then update the route in YAML:
Suggested modules
- xddesigners/silverstripe-ai-assistant — adds a ready-to-use AI Assistant tab to CMS edit forms, letting editors generate and preview AI-written content for any configured fields.
License
BSD-3-Clause © XD Designers
All versions of silverstripe-ai with dependencies
symfony/ai-platform Version ^0.3.0
symfony/ai-open-ai-platform Version ^0.3.0
symfony/ai-anthropic-platform Version ^0.3.0
symfony/ai-azure-platform Version ^0.3.0
symfony/ai-vertex-ai-platform Version ^0.3.0
symfony/ai-open-router-platform Version ^0.3.0
symfony/ai-gemini-platform Version ^0.3.0
symfony/ai-generic-platform Version ^0.3.0
symfony/ai-mistral-platform Version ^0.3.0
symfony/http-client Version ^7.4
symfony/dotenv Version ^7.4