Jean Lúcio
Lead maintainer
AI Hub is a small BYOK (bring your own key) broker for Moodle. It lets the institution's own plugins generate text through shared AI API keys, without each plugin reimplementing the HTTP transport, the SSRF guard, the provider ladder or a key store.
👥 Who it is for: developers of sibling Moodle plugins who want AI text generation without building their own provider integration, and site administrators who want a single place to manage AI keys, opt-in personal keys, and usage reporting across the site.
class_exists() check, so AI Hub can be installed and updated independently.AI Hub does not charge for usage and does not resell access to any provider. Once an administrator or a user configures a key, the prompt text is sent to the matching third-party provider (Google Gemini, Groq, DeepSeek, or a configured OpenAI-compatible endpoint) to generate the response. Any usage costs, quotas or terms are set directly by that provider, not by this plugin. See the Third-party Service Disclosure in the documentation for exact endpoints and data handling.
\local_aihub\ai::generate_text() and is_available() — consumed by sibling plugins through a soft dependency (class_exists), with no hard dependency entry.local/aihub:viewusage.The hub resolves a key tier by tier and stops at the first tier that holds a key:
| Tier | Source |
|---|---|
| 1 | Personal key — the user's own key, when personal keys are enabled and the user has local/aihub:usepersonalkey |
| 2 | Site key — the admin key set in the hub settings |
Within the chosen tier, providers are tried in the order Gemini → Groq → DeepSeek → OpenAI-compatible (first key found is used; if its call fails, the next provider in the same tier is tried). When no tier holds a key, generate_text() returns success = false — the hub never falls back to core_ai; that decision belongs to the consumer.
local/aihub and complete the Moodle upgrade as usual.local/aihub:usepersonalkey capability, open My AI keys in your preferences to add your own key.\local_aihub\ai::generate_text() behind a class_exists() guard in your own plugin, keeping your own core_ai fallback.local/aihub:viewusage) to see every request served by the site keys across all users, with CSV and Excel download.local/aihub:usepersonalkey and the site toggle).admin_setting_configpasswordunmask; the SSRF guard protects the configurable endpoint.require_sesskey() on the key form; capability local/aihub:viewusage on the usage report.Full documentation — the developer facade, the BYOK key-resolution ladder, usage guide and full test suite — is published at jeanlucio.github.io/moodle-local_aihub. Found a bug or have a question? Open an issue on the issue tracker.
This project is licensed under the GNU General Public License v3 (GPLv3).
Copyright: 2026 Jean Lúcio