OpenAI API provider
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
Moodle integration with OpenAI provides a service that lets people use advanced AI tools like generate a text, generate an image or summarise a text.
More information about OpenAI can be found at https://platform.openai.com
Requirements:
A paid OpenAI account with access to the API key (Usage limits and pricing tiers are dependent on the level of access and the volume of queries). In Moodle LMS 4.5.0, both an OpenAI API key and OpenAI organization ID are required, however the organization ID will become optional from 4.5.1.
When setting up an OpenAI account with an API key, site administrators can generate keys with both free and paid accounts, however API usage is restricted based on the account type and payment method. Access to the API used by the Moodle LMS integration requires a subscription to one of OpenAI’s paid plans, such as the Pay-as-you-go or Pro/Enterprise plan, which provide different levels of access depending on the selected pricing tier.
Configuring OpenAI API provider settings
- Go to Site administration -> General -> AI -> AI providers.
- Enable the "OpenAI API Provider" by clicking on the “Enabled” toggle.
- Click on the "OpenAI API Provider" settings link.
- In the “Settings” area proceed to configure the following:
- OpenAI API key: You can get the key from your OpenAI account / API Keys (OpenAI API keys).
- OpenAI organization ID: You find this in your OpenAI account / Organization settings page (OpenAI account). (This is a required field for Moodle LMS 4.5.0, but will be optional from 4.5.1.)
- Set site-wide rate limit: An optional feature to limit the number of requests that the OpenAI API Provider can receive across the entire site every hour.
- Maximum number of site-wide requests can be configured after enable “Set site-wide rate limit”.
- Set user rate limit: An optional feature to limit the number of AI requests each user can make to this provider each hour.
- Maximum number of requests per user can be configured after enable “Set user rate limit”
- In the “Actions” area you can control which available Actions are enabled and configure further Action settings.
Configuring OpenAI API Provider actions
The following Action settings are available for the OpenAI Provider.
Generate text: You can configure the following settings:
- AI model: OpenAI API is powered by a diverse set of models with different capabilities and price points. There is more information about at OpenAI Models. By default, the model is set to “GPT-4o”, but this can be configured to any other compatible model. For more details, see your organization's settings and limits information.
- API endpoint. Please ensure your API endpoint is compatible with your selected model. For more information, visit Model endpoint compatibility.
- System instruction: There are default system instructions in place, but these can be customised to suit your specific needs.
Summarise text: The required configuration is the same as for the Generate text Action.
Generate image: You can configure the following settings:
- AI model: The default is set to “dall-e-3” but it can be changed to any other image generation compatible model. For more details, visit: DALL-E Models.
- API endpoint: Please ensure your API endpoint is compatible with your selected model.
With the above enabled and configured, the OpenAI Provider can be used for the AI Placements available in your Moodle LMS instance; Course Assistance and HTML Text Editor Placements. Don't forget to also enable and configure AI Placements settings.