Adds an AI assistant to the Payload admin dashboard and to document edit views. It reads CMS context, supports mentions, and proposes create, update, delete and global changes that are signed and checked against Payload access control before applying. Providers include OpenAI, Anthropic, Google, Mistral and OpenRouter, and the matching provider SDK must be installed. PAYLOAD_SECRET is required for signing.
AI assistant plugin for Payload CMS with provider selection, CMS mentions, and signed action proposals.
Installation
npm i @mvriu5/payload-ai4
Stars
0
Forks
6
Open Issues
3 weeks ago
Last Updated
288
Weekly Downloads
v1.6.4
npm Version
514.3 KB
Unpacked Size
2
Dependencies
40 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 4 |
| Dec 4, 2026 | 4 |
| Dec 3, 2026 | 4 |
| Dec 2, 2026 | 4 |
| Dec 1, 2026 | 4 |
| Nov 30, 2026 | 4 |
| Nov 29, 2026 | 4 |
| Nov 28, 2026 | 4 |
| Nov 27, 2026 | 4 |
| Nov 26, 2026 | 4 |
| Nov 25, 2026 | 4 |
| Nov 24, 2026 | 4 |
| Nov 23, 2026 | 4 |
| Nov 22, 2026 | 4 |
| Nov 21, 2026 | 4 |
| Nov 20, 2026 | 4 |
| Nov 19, 2026 | 4 |
| Nov 18, 2026 | 4 |
| Nov 17, 2026 | 4 |
| Nov 16, 2026 | 4 |
| Nov 15, 2026 | 4 |
| Nov 14, 2026 | 4 |
| Nov 13, 2026 | 4 |
| Nov 12, 2026 | 4 |
| Nov 11, 2026 | 4 |
| Nov 10, 2026 | 4 |
| Nov 9, 2026 | 4 |
| Nov 8, 2026 | 4 |
| Nov 7, 2026 | 4 |
| Nov 6, 2026 | 4 |
| Nov 5, 2026 | 4 |
| Nov 4, 2026 | 4 |
| Nov 3, 2026 | 4 |
| Nov 2, 2026 | 4 |
| Nov 1, 2026 | 4 |
| Oct 31, 2026 | 4 |
| Oct 30, 2026 | 4 |
| Oct 29, 2026 | 4 |
| Oct 28, 2026 | 4 |
| Oct 27, 2026 | 4 |
| Oct 26, 2026 | 4 |
| Oct 25, 2026 | 4 |
| Oct 24, 2026 | 4 |
| Oct 23, 2026 | 4 |
| Oct 22, 2026 | 4 |
| Oct 21, 2026 | 4 |
| Oct 20, 2026 | 4 |
| Oct 19, 2026 | 4 |
| Oct 18, 2026 | 4 |
| Oct 17, 2026 | 4 |
| Oct 16, 2026 | 4 |
| Oct 15, 2026 | 4 |
| Oct 14, 2026 | 4 |
| Oct 13, 2026 | 4 |
| Oct 12, 2026 | 4 |
| Oct 11, 2026 | 4 |
| Oct 10, 2026 | 4 |
| Oct 9, 2026 | 4 |
| Oct 8, 2026 | 4 |
| Oct 7, 2026 | 4 |
| Oct 6, 2026 | 4 |
| Oct 5, 2026 | 4 |
| Oct 4, 2026 | 4 |
| Oct 3, 2026 | 4 |
| Oct 2, 2026 | 4 |
| Oct 1, 2026 | 4 |
| Sep 30, 2026 | 4 |
| Sep 29, 2026 | 4 |
| Sep 28, 2026 | 4 |
| Sep 27, 2026 | 4 |
| Sep 26, 2026 | 4 |
| Sep 25, 2026 | 4 |
| Sep 24, 2026 | 4 |
| Sep 23, 2026 | 4 |
| Sep 22, 2026 | 4 |
| Sep 21, 2026 | 4 |
| Sep 20, 2026 | 4 |
| Sep 19, 2026 | 4 |
| Sep 18, 2026 | 4 |
| Sep 17, 2026 | 4 |
| Sep 16, 2026 | 4 |
| Sep 15, 2026 | 4 |
| Sep 14, 2026 | 4 |
| Sep 13, 2026 | 4 |
| Sep 12, 2026 | 4 |
| Sep 11, 2026 | 4 |
| Sep 10, 2026 | 4 |
| Sep 9, 2026 | 4 |
| Sep 8, 2026 | 4 |
| Sep 7, 2026 | 4 |
| Sep 6, 2026 | 4 |
251+141 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 251 |
| Dec 4, 2026 | 198 |
| Dec 3, 2026 | 154 |
| Dec 2, 2026 | 75 |
| Dec 1, 2026 | 144 |
| Nov 30, 2026 | 153 |
| Nov 29, 2026 | 147 |
| Nov 28, 2026 | 142 |
| Nov 27, 2026 | 140 |
| Nov 26, 2026 | 144 |
| Nov 25, 2026 | 167 |
| Nov 24, 2026 | 125 |
| Nov 23, 2026 | 168 |
| Nov 22, 2026 | 167 |
| Nov 21, 2026 | 201 |
| Nov 20, 2026 | 200 |
| Nov 19, 2026 | 201 |
| Nov 18, 2026 | 197 |
| Nov 17, 2026 | 176 |
| Nov 16, 2026 | 136 |
| Nov 15, 2026 | 189 |
| Nov 14, 2026 | 169 |
| Nov 13, 2026 | 162 |
| Nov 12, 2026 | 156 |
| Nov 11, 2026 | 134 |
| Nov 10, 2026 | 154 |
| Nov 9, 2026 | 137 |
| Nov 8, 2026 | 95 |
| Nov 7, 2026 | 92 |
| Nov 6, 2026 | 105 |
| Nov 5, 2026 | 112 |
| Nov 4, 2026 | 113 |
| Nov 3, 2026 | 94 |
| Nov 2, 2026 | 104 |
| Nov 1, 2026 | 95 |
| Oct 31, 2026 | 92 |
| Oct 30, 2026 | 88 |
| Oct 29, 2026 | 74 |
| Oct 28, 2026 | 65 |
| Oct 27, 2026 | 64 |
| Oct 26, 2026 | 61 |
| Oct 25, 2026 | 62 |
| Oct 24, 2026 | 62 |
| Oct 23, 2026 | 50 |
| Oct 22, 2026 | 71 |
| Oct 21, 2026 | 88 |
| Oct 20, 2026 | 85 |
| Oct 19, 2026 | 93 |
| Oct 18, 2026 | 127 |
| Oct 17, 2026 | 113 |
| Oct 16, 2026 | 128 |
| Oct 15, 2026 | 137 |
| Oct 14, 2026 | 147 |
| Oct 13, 2026 | 183 |
| Oct 12, 2026 | 163 |
| Oct 11, 2026 | 144 |
| Oct 10, 2026 | 184 |
| Oct 9, 2026 | 187 |
| Oct 8, 2026 | 163 |
| Oct 7, 2026 | 140 |
| Oct 6, 2026 | 112 |
| Oct 5, 2026 | 134 |
| Oct 4, 2026 | 123 |
| Oct 3, 2026 | 90 |
| Oct 2, 2026 | 88 |
| Oct 1, 2026 | 89 |
| Sep 30, 2026 | 93 |
| Sep 29, 2026 | 92 |
| Sep 28, 2026 | 83 |
| Sep 27, 2026 | 76 |
| Sep 26, 2026 | 96 |
| Sep 25, 2026 | 102 |
| Sep 24, 2026 | 109 |
| Sep 23, 2026 | 116 |
| Sep 22, 2026 | 117 |
| Sep 21, 2026 | 135 |
| Sep 20, 2026 | 145 |
| Sep 19, 2026 | 134 |
| Sep 18, 2026 | 138 |
| Sep 17, 2026 | 139 |
| Sep 16, 2026 | 136 |
| Sep 15, 2026 | 137 |
| Sep 14, 2026 | 119 |
| Sep 13, 2026 | 118 |
| Sep 12, 2026 | 143 |
| Sep 11, 2026 | 126 |
| Sep 10, 2026 | 122 |
| Sep 9, 2026 | 125 |
| Sep 8, 2026 | 120 |
| Sep 7, 2026 | 115 |
| Sep 6, 2026 | 110 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1255332434-root)<a href="https://payloaddirectory.dev/plugins/1255332434-root"><img src="https://payloaddirectory.dev/badge/1255332434-root.svg" alt="Payload Directory"></a>README
AI assistant plugin for Payload CMS. It adds an admin dashboard assistant that can read CMS context, use mentions, and create signed action proposals for create, update, delete, and global updates.
npm add @mvriu5/payload-ai @ai-sdk/openai
Install only the provider SDKs you actually use:
npm add @mvriu5/payload-ai @ai-sdk/anthropic
npm add @mvriu5/payload-ai @ai-sdk/google
npm add @mvriu5/payload-ai @ai-sdk/mistral
OpenRouter uses the community OpenRouter provider:
npm add @mvriu5/payload-ai @openrouter/ai-sdk-provider
import { buildConfig } from "payload"
import { payloadAiPlugin } from "@mvriu5/payload-ai"
export default buildConfig({
plugins: [
payloadAiPlugin({
collections: {
posts: true,
},
}),
],
})
Without centrally configured providers, the plugin adds two fields to the configured Payload admin user collection:
aiProvideraiApiKeyUsers can select their provider and optionally store their own API key in account settings. If no account-level key is set, the chat endpoint uses provider environment variables.
When providers is configured, provider selection and API keys are managed centrally. The plugin does not add either field to the user collection. All configured provider models are grouped by provider in the AI input.
import type { PayloadAIPluginOptions } from "@mvriu5/payload-ai"
const options: PayloadAIPluginOptions = {
aiInput: true,
allowUserApiKeys: false,
authCollections: {
aiInput: false,
generateFields: false,
},
collections: {
media: {
read: true,
update: true,
},
posts: {
read: true,
create: true,
update: true,
delete: false,
},
users: true,
},
generateFields: true,
media: {
enabled: true,
collectionSlug: "media",
acceptedMimeTypes: ["image/*"],
maxFileSize: 10 * 1024 * 1024,
},
providers: [
{
id: "company-openai",
label: "Company OpenAI",
provider: "openai",
apiKey: process.env.COMPANY_OPENAI_API_KEY,
models: [
{ label: "GPT-4.1 Mini", value: "gpt-4.1-mini" },
{ label: "GPT-4.1", value: "gpt-4.1" },
],
defaultModel: "gpt-4.1-mini",
},
{
id: "ollama",
label: "Local Ollama",
provider: "openai",
baseURL: "http://localhost:11434/v1",
apiKey: "ollama",
models: [
{ label: "Llama 3.3", value: "llama3.3" },
{ label: "Qwen 3", value: "qwen3" },
],
},
],
maxOutputTokens: 1200,
promptCaching: true,
translate: true,
uploadCollections: {
aiInput: true,
generateFields: false,
},
maxTokenUsage: {
type: "user",
perDay: 50_000,
perWeek: 250_000,
},
}
models configures model choices for the user-selected provider mode. Use providers instead when provider selection, credentials, and endpoints should be managed centrally.
aiInputControls whether the collapsible AI Assistant input is added to collection and global edit views. It defaults to true.
payloadAiPlugin({
aiInput: false,
})
Disabling this option does not remove the AI dashboard or per-field Generate controls.
generateFieldsControls whether supported fields receive a Generate control. It defaults to true.
payloadAiPlugin({
generateFields: false,
})
Generate controls are added to text, textarea, richText, and json fields in collection and global edit views. When disabled, the plugin also omits the /ai-generate-field endpoint. The embedded AI Assistant and dashboard remain available.
authCollections and uploadCollectionsAuth and upload collections do not receive the embedded AI Assistant or Generate controls by default. Enable either feature explicitly for the respective collection type:
payloadAiPlugin({
authCollections: {
aiInput: true,
generateFields: true,
},
uploadCollections: {
aiInput: true,
generateFields: true,
},
})
The global aiInput and generateFields options still take precedence when set to false.
translateControls document translation for localized collections and globals. It defaults to true.
payloadAiPlugin({
translate: false,
})
When enabled, the plugin adds a Translate action to the document header. It is shown only when:
Translation fills only empty localized fields in the current Payload form and marks it as modified. Existing translated values are never overwritten. It does not save the document or global, so the generated values can be reviewed and validated before saving.
When disabled, the plugin does not register the header control or the /ai-translate-document endpoint.
collectionsRestricts AI read and write proposals to enabled collection slugs. If omitted, all non-internal Payload collections are available.
Use true to enable all AI actions for a collection:
payloadAiPlugin({
collections: {
posts: true,
},
})
Use granular permissions to control each action:
payloadAiPlugin({
collections: {
posts: {
read: true,
create: true,
update: true,
delete: false,
},
},
})
You can mix both forms in the same object:
payloadAiPlugin({
collections: {
posts: true,
pages: true,
users: {
read: true,
update: true,
},
},
})
read controls schema/context access, document search, and mentions. create, update, and delete control AI action proposals and server-side apply permissions.
mediaEnables media uploads from the AI assistant. Uploaded files are created through the configured Payload upload collection and then passed to the chat endpoint as media attachments.
payloadAiPlugin({
collections: {
media: {
read: true,
update: true,
},
posts: true,
},
media: {
enabled: true,
collectionSlug: "media",
acceptedMimeTypes: ["image/*"],
maxFileSize: 10 * 1024 * 1024,
},
})
collectionSlug defaults to "media". The target collection must be configured with Payload upload support.
acceptedMimeTypes accepts exact MIME types such as "image/png" and wildcard groups such as "image/*". If omitted, all file types accepted by the upload collection can be sent to the endpoint.
maxFileSize is checked before creating the upload document. The value is in bytes.
If you want the AI to use uploaded files in other documents, enable read on the media collection so the chat endpoint can validate and inspect the uploaded media document. If the media collection has editable fields such as alt, caption, or credit and you want the AI to fill them, also enable update for that collection.
Upload references in AI proposals are restricted to the uploaded attachments for the current request. This prevents the model from inventing arbitrary media IDs for upload fields.
modelsOverrides the model list shown in the admin UI and the default model per provider.
Built-in providers are openai, openrouter, claude, mistral, and google.
The built-in model selection was checked on October 6, 2026 against the official OpenAI, Anthropic, Google, Mistral, and OpenRouter catalogs. It includes a broad selection of current and older text models for the streaming tool loop. Preview and deprecated direct-provider models are labeled explicitly and are not defaults.
The defaults are gpt-6-luna, claude-haiku-4-5, gemini-3.8-flash, mistral-small-2603, and openrouter/auto. Each provider's first model is used unless you configure a different default.
The built-in options cover these model families:
openrouter/auto, current and older OpenAI/Claude/Gemini/Mistral models, GPT-OSS, DeepSeek, Qwen, Grok, Llama, GLM, Kimi, and MiniMax.The exact model IDs are defined in src/features/providers/options.ts. This is a static selection, not an automatically synchronized catalog. Models known to be retired on the direct APIs are excluded; OpenRouter is checked separately because it may still serve older models through other providers. Its listed models advertise support for both tools and tool_choice.
Deprecated models are retained as optional choices for existing integrations and may be removed by their provider. Availability also depends on your account: for example, Gemini 2.5 is restricted to existing users. Live inference is not verified by the model list.
providersEnables centrally managed provider profiles. Each profile supports:
id: unique provider profile identifierlabel: provider group label shown in the model selectprovider: SDK adapter (openai, openrouter, claude, mistral, or google)models: allowed model listdefaultModel: optional default; otherwise the first configured model is usedbaseURL: optional custom provider URLapiKey: optional server-side API keyWhen at least one profile is configured:
aiProvider and aiApiKey are not added to the admin user collection.apiKey and baseURL remain server-side and are not included in Payload's public admin configuration. Custom endpoints must implement the protocol expected by their selected SDK adapter. For Ollama, vLLM, and similar APIs, use the openai adapter with an OpenAI-compatible /v1 endpoint.
maxOutputTokensControls the maximum number of output tokens the chat endpoint may generate per request. If omitted, the plugin uses 700.
payloadAiPlugin({
maxOutputTokens: 1200,
})
maxTokenUsageLimits total AI tokens across rolling 24-hour and 7-day windows.
payloadAiPlugin({
maxTokenUsage: {
type: "user",
perDay: 50_000,
perWeek: 250_000,
},
})
Use type: "user" to enforce separate budgets per authenticated user, or type: "site" to share one budget across the entire Payload installation. perDay and perWeek are optional individually, but at least one must be configured.
Completed model usage is stored in the hidden payload-ai-usage collection. Requests made after a limit is reached return HTTP 429. Because providers report token usage after completion, the request that crosses a limit is allowed to finish and subsequent requests are blocked.
promptCachingEnables provider prompt-caching hints and defaults to true. The chat endpoint keeps static instructions and Payload schemas in a stable prompt prefix, adds Anthropic cache-control breakpoints, and supplies a stable OpenAI prompt cache key. Gemini uses the same stable prefix with its implicit caching.
payloadAiPlugin({
promptCaching: false,
})
Disable it when explicit provider-side caching is not desired. Dynamic document data and user prompts are never placed in the cacheable schema section. Managed providers with a custom baseURL receive the stable prefix but no provider-specific cache parameters, preserving compatibility with Ollama, vLLM, and other OpenAI-compatible endpoints.
allowUserApiKeysControls whether the plugin adds an aiApiKey field to the admin user collection.
payloadAiPlugin({
allowUserApiKeys: false,
})
When disabled, users can still select an AI provider, but API keys must come from environment variables.
This option only applies when providers is not configured. Managed provider mode never adds user-level AI settings.
disabledDisables endpoint and UI registration while keeping the plugin call in your config.
The package lazy-loads provider SDKs at runtime. If a user selects claude, google, mistral, openai, or openrouter, the matching provider package must be installed in the host app.
openrouter uses @openrouter/ai-sdk-provider.
API key priority is:
apiKey, when providers is configuredallowUserApiKeys: falseOPENAI_API_KEY, OPENAI_MODELOPENROUTER_API_KEY, OPENROUTER_MODELANTHROPIC_API_KEY, ANTHROPIC_MODELGOOGLE_GENERATIVE_AI_API_KEY, GOOGLE_GENERATIVE_AI_MODELMISTRAL_API_KEY, MISTRAL_MODELPAYLOAD_SECRET is required for signing AI action proposals.
AI write operations are proposal-based. The chat endpoint signs every proposal with an HMAC signature and a short TTL. The apply endpoint verifies the signature, validates the target collection/global, enforces Payload access control with overrideAccess: false, and rejects proposals containing sensitive API-key-like fields.
The apply endpoint returns only minimal status/doc references and does not return normalized data, proposal payloads, API keys, or raw error details to the client.
import { payloadAiPlugin } from "@mvriu5/payload-ai"
import type { PayloadAiPluginOptions } from "@mvriu5/payload-ai"
Client components are exported through:
import { AIInput, AIApiKeyField } from "@mvriu5/payload-ai/client"
payload ai manager
Generate product titles, descriptions, attributes and translations with Claude, ChatGPT, Gemini or Kimi
7022/wk1v3
payload agent
AI chat agent that queries and manages Payload content from Telegram, Slack, WhatsApp and other chat platforms
5774/wk17v3
payload plugin ai chat
Adds ChatGPT-style chat to Payload collections using OpenAI models
3312/wk15v1
payload plugin ai completions
Generate field content in the Payload admin with OpenAI completions using configurable per-field prompts
2812/wk8v1
payload ai
AI text, image and voice generation for Payload fields and the Lexical editor with configurable providers
833.5k/wk568v3
seo
Fork of the official Payload SEO plugin that generates meta titles and descriptions with OpenAI
48115/wk335v3