The AI features are optional. Without them every page works; with them the dashboard gains three helpers. Nothing the AI writes is saved until a person saves it.
Switching it on
Set in .env and restart:
AI_BASE_URL="https://api.openai.com/v1" # or OpenRouter, Azure OpenAI, a local Ollama: http://localhost:11434/v1
AI_API_KEY="..." # if your provider needs one
AI_MODEL="gpt-4o-mini" # the model name your provider expects
The code calls {AI_BASE_URL}/chat/completions (see src/lib/ai.ts), so any service that speaks the OpenAI chat format works, including models you host yourself. Who may use the AI is the AI assistant permission (Dashboard > Admin roles).
1. Write course descriptions
Course editor > Description > Write with AI. The assistant reads the course titles, category, level and the list of sections and lessons, and drafts the subtitle, a two-paragraph description and four learning outcomes in Arabic and English. It is told to use only what the syllabus says and never to promise jobs, salaries or accreditation. The draft fills the form; review it and press Save.
2. Draft quiz questions from a lesson
Quiz builder > Draft questions with AI > choose a lesson. The assistant reads the lesson text in both languages and proposes four multiple-choice or true/false questions with explanations. Invalid drafts (no right answer, wrong number of options) are dropped, never repaired silently. Add the ones you like with Add to quiz.
3. Ask about your academy
Dashboard > AI assistant. Ask in Arabic or English, for example "Where do learners get stuck?". The assistant receives a text snapshot of the data your role may see (an instructor only their courses): this month's figures, monthly revenue or earnings, enrolments by category and by day, courses where learners stall, the hardest quizzes, upcoming sessions and the course list. Learners' emails are never included. It can only read this snapshot; it cannot change anything.
The right column of the page works without AI: Where learners stall (enrolled three weeks ago or more and still under 30%) and Hardest quizzes (failed attempts share) are computed directly from the database (src/lib/assistant.ts).
Limits and cost
Each request is rate-limited per account (10 drafts and 20 questions a minute) and has a time limit. Costs depend on your provider; drafts send a lesson or a syllabus, the chat sends a snapshot of a few thousand characters.