Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
import { NextResponse, type NextRequest } from 'next/server'
import { hasProviderForSlotForUser } from '@/lib/ai/provider'
import { stockPhotoAvailable } from '@/lib/stock-photo'
import { stockSoundAvailable } from '@/lib/stock-sound'
import { getFeatures } from '@/lib/admin/config'
import { getSessionUser } from '@/lib/auth/session'
import { withLogging } from '@/lib/observability'
export const runtime = 'nodejs'
export const dynamic = 'force-dynamic'
/**
* GET /api/ai/capabilities
* Public, secret-free feature detection. Panels use these boolean flags to
* show "requires server AI provider" states before the user tries a feature.
* Only ever exposes which capabilities exist — never config, never keys.
*/
async function __canvix_get(req: NextRequest) {
// v0.16 (A1): a capability is available when a provider answers AND
// the admin console has not switched the feature off. v0.16.2 (A2):
// the provider check is per capability SLOT — with the multi-provider
// table you can wire text to one vendor and images to another, so
// "a provider exists" is no longer a single boolean. Still booleans
// only — never config, never keys, never which layer answered.
// v0.16.4 (A4): photoSearch left the AI table — it answers on the
// stock-provider keys (Pexels/Pixabay), like the Videos rail.
// v0.19 (Wave 4): five AI Power-Up capabilities — the text-slot
// trio (plan/notes/theme), vision-slot alt text, the video slot,
// and the two LOCAL image tools that need no provider at all.
// Sound wave: soundSearch rides the Freesound stock key.
// v0.23 (BYOK): when the request carries a session, the user's saved
// providers answer the probes first — so people who bring their own keys
// see the AI features enabled even on an unconfigured instance. Anonymous
// requests resolve the instance-wide slots exactly as before. Booleans
// only, still — never config, never keys.
const user = await getSessionUser(req)
const uid = user?.id ?? null
const [text, vision, image, imageEdit, video, stockPhotos, stockSounds] = await Promise.all([
hasProviderForSlotForUser('text', uid),
hasProviderForSlotForUser('vision', uid),
hasProviderForSlotForUser('image', uid),
hasProviderForSlotForUser('imageEdit', uid),
hasProviderForSlotForUser('video', uid),
stockPhotoAvailable(), // async since A5 — keys resolve console-first
stockSoundAvailable(),
])
const configured = text || vision || image || imageEdit || video
const flags = await getFeatures()
return NextResponse.json({
configured,
capabilities: {
magicWrite: text && flags.magicWrite,
imageGeneration: image && flags.imageGeneration,
imageEditing: imageEdit && flags.imageEditing,
vision: vision && flags.vision, // Magic Layers
translation: text && flags.translation,
assistant: text && flags.assistant,
photoSearch: stockPhotos && flags.photoSearch, // stock keys, not a model slot
soundSearch: stockSounds && flags.soundSearch, // Freesound stock key
backgroundRemoval: true, // local ONNX — always available
colorPalette: true, // local deterministic
layoutSuggestions: true, // local deterministic
// v0.19 (Wave 4 — AI Power-Up):
agenticPlanning: text && flags.agenticPlanning, // plan → review gate → apply
notesGeneration: text && flags.notesGeneration, // speaker notes
themeGeneration: text && flags.themeGeneration, // palette + fonts
altText: vision && flags.altText, // image alt text
videoGeneration: video && flags.videoGeneration, // text-to-video slot
// v0.31 (DesignAgent panel): the autonomous pipeline — needs the
// text slot (planning/revision); the vision slot is OPTIONAL
// (visual verification discloses 'unavailable' without it)
designAgent: text && flags.designAgent,
upscale: true, // local Lanczos — always available
brushEraser: true, // local inpainting — always available
},
})
}
// v0.12.5 (H7): opt-in request logging wrapper — passthrough
// unless CANVIX_LOG=requests (see src/lib/observability.ts)
export const GET = withLogging('GET /api/ai/capabilities', __canvix_get)