AI assistant
Add the AI assistant that writes, revises and redesigns slides, and choose how it connects to models.
The AI assistant is a side panel: the user describes the presentation, the assistant drafts an outline and, once it is confirmed, builds the slides; it also revises existing slides, unifies their style, adds pictures and checks layouts. Every change the assistant makes enters the undo history, and changes to existing content are shown for review first.
Install
pnpm add @quirekit/ai-assistant @quirekit/ai-chat @quirekit/ai-runtime @quirekit/ai-orchestrator-pi @quirekit/ai-contract
These are optional peer dependencies of @quirekit/pptx-editor; skip them when you do not use AI.
Add the assistant
import { Editor } from '@quirekit/pptx-editor'
import { createPptxEditorAi } from '@quirekit/pptx-editor/ai'
const ai = createPptxEditorAi({ ownerDocument: document, storage: window.localStorage })
const editor = new Editor({ panels: [ai.panel] }).mount('#app')
window.addEventListener('pagehide', () => { editor.destroy(); ai.destroy() }, { once: true })
storage keeps the user's model settings, selected model and authorization mode. Call ai.destroy() when the page no longer needs the assistant.
Connect to models
| Mode | Configuration | Suits |
|---|---|---|
| Browser direct | No connection options; users enter a provider API key in the assistant settings | Personal use, internal trials |
| Your model service | defaultHostUrl: 'https://ai.example.com', with getHeaders for credentials when needed | Keys stay on the server, central billing and audit |
| App-managed models | connection: () => resolveQuireAiModelConnection({ hostUrl, getHeaders }) | Users do not configure models themselves |
In browser direct mode, keys stay in the user's browser storage; never put keys in front-end code. Your own model service provides the QuireKit AI Host interface (model catalog and message stream), which the Host runtime of @quirekit/ai-orchestrator-pi calls.
Pictures
The assistant can generate pictures from a description. By default it uses a connected provider that generates pictures; the host can provide its own picture service instead:
createPptxEditorAi({
ownerDocument: document,
storage: window.localStorage,
pictures: {
generate: async ({ prompt, width, height, signal }) => {
const response = await fetch('/api/images', { method: 'POST', body: JSON.stringify({ prompt, width, height }), signal })
return new Uint8Array(await response.arrayBuffer())
},
},
})
With pictures: false the assistant uses icons and shapes only.
Other options
defaultOpen: true: opens the assistant when the editor mounts.providers: the providers offered in the settings; the built-in ones by default.skills: the design knowledge the assistant reads; the built-in design method and scene skills by default.documentKey: false: keeps one unsaved conversation instead of storing conversations per deck.