OpenAI API provider: Difference between revisions

From MoodleDocs
mNo edit summary
Update doc
Line 1: Line 1:
{{AI subsystem}}
{{AI subsystem}}
{{Work in progress}}
{{New features}}
{{New features}}


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.
Moodle LMS’s integration with OpenAI provides access to AI Actions such as generate text, generate image or summarise course content.  


More information about OpenAI can be found at https://platform.openai.com  
More information about OpenAI can be found at https://platform.openai.com.


=== Requirements: ===
===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.
An OpenAI account with access to a paid API key. 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.
When setting up an OpenAI account with an API key, although keys can be generate by both free and paid accounts, API usage is restricted based on the paid tokens available on the account. '''Access to the API used by the Moodle LMS integration requires a subscription to one of OpenAI’s paid API plans''' (such as pay-as-you-go). Access, usage limits and pricing tiers are dependent on the model used, so it is best to check the [https://openai.com/api/pricing/ OpenAI API pricing page] for the latest information.


=== Configuring OpenAI API provider settings ===
===Configuring OpenAI API Provider settings===
# Go to Site administration -> General -> AI -> AI providers.
#Go to Site administration -> General -> AI -> AI providers.
# Enable the "OpenAI API Provider" by clicking on the “Enabled” toggle.
#Enable the "OpenAI API Provider" by clicking on the “Enabled” toggle.
# Click on the "OpenAI API Provider" settings link.
#Click on the "OpenAI API Provider" settings link.
# In the “Settings” area proceed to configure the following:  
#In the “Settings” area proceed to configure the following:  
#* OpenAI API key: You can get the key from your OpenAI account / API Keys ([https://platform.openai.com/account/api-keys OpenAI API keys]).
#*OpenAI API key: You can get the key from your OpenAI account / API Keys ([https://platform.openai.com/account/api-keys OpenAI API keys]).
#* OpenAI organization ID: You find this in  your OpenAI account / Organization settings page ([https://platform.openai.com/account/org-settings OpenAI account]). (This is a required field for Moodle LMS 4.5.0, but will be optional from 4.5.1.)
#*OpenAI organization ID: You find this in  your OpenAI account / Organization settings page ([https://platform.openai.com/account/org-settings 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.  
#*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”.
#* 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.
#*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”
#*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.<br />
# In the “Actions” area you can control which available Actions are enabled and configure further Action settings.<br />


Line 29: Line 28:
[[File:OpenAI Actions.png|none|thumb|600x600px|OpenAI Actions]]
[[File:OpenAI Actions.png|none|thumb|600x600px|OpenAI Actions]]
   
   
The following Action settings are available for the OpenAI Provider.
The following Action settings are available for the OpenAI Provider.  


'''Generate text:''' You can configure the following settings:  
'''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 [https://platform.openai.com/docs/models 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 [https://platform.openai.com/settings/organization/limits your organization's settings and limits information].  
* AI model: OpenAI API is powered by a diverse set of models with different capabilities and price points. There is more information about at [https://platform.openai.com/docs/models OpenAI Models]. By default, the model is set to “GPT-4o”,  but this can be configured to any other compatible model. For more details, [https://platform.openai.com/settings/organization/limits 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 [https://platform.openai.com/docs/models/model-endpoint-compatibility Model endpoint compatibility].
*System instruction: There are default system instructions in place to help direct the expected response format from the AI, but these can be customised to suit your specific needs. These are used to ensure a smooth user experience where only the requested text generation is returned, with no salutations, repetition of the request etc. It is therefore recommended these are not modified unless you are confident the change is absolutely necessary.


*API endpoint. Please ensure your API endpoint is compatible with your selected model. For more information, visit [https://platform.openai.com/docs/models/model-endpoint-compatibility 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.  
'''Summarise text:''' The required configuration is the same as for the Generate text Action.  


Line 45: Line 45:
*API endpoint:  Please ensure your API endpoint is compatible with your selected model.
*API endpoint:  Please ensure your API endpoint is compatible with your selected model.


[[File:Generate text in OpenAI.png|none|thumb|600x600px|Generate text in OpenAI]]
 
With all of the above enabled and configured, the OpenAI Provider can be used for all of 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|AI Placements]] settings. [[File:Generate text in OpenAI.png|none|thumb|600x600px|Settings to generate text in OpenAI]]
[[File:Generate AI Image.png|none|thumb|600x600px|Settings to generate image in OpenAI]]






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|AI Placements]]''' settings. 


[[es:Proveedor OpenAI API]]
[[es:Proveedor OpenAI API]]

Revision as of 13:19, 18 October 2024

New feature
in Moodle 5.2!


Moodle LMS’s integration with OpenAI provides access to AI Actions such as generate text, generate image or summarise course content.

More information about OpenAI can be found at https://platform.openai.com.

Requirements:

An OpenAI account with access to a paid API key. 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, although keys can be generate by both free and paid accounts, API usage is restricted based on the paid tokens available on the account. Access to the API used by the Moodle LMS integration requires a subscription to one of OpenAI’s paid API plans (such as pay-as-you-go). Access, usage limits and pricing tiers are dependent on the model used, so it is best to check the OpenAI API pricing page for the latest information.

Configuring OpenAI API Provider settings

  1. Go to Site administration -> General -> AI -> AI providers.
  2. Enable the "OpenAI API Provider" by clicking on the “Enabled” toggle.
  3. Click on the "OpenAI API Provider" settings link.
  4. 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”.
  5. In the “Actions” area you can control which available Actions are enabled and configure further Action settings.

Configuring OpenAI API Provider actions

OpenAI Actions

The following Action settings are available for the OpenAI Provider.

Generate text: You can configure the following settings:

  • 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 to help direct the expected response format from the AI, but these can be customised to suit your specific needs. These are used to ensure a smooth user experience where only the requested text generation is returned, with no salutations, repetition of the request etc. It is therefore recommended these are not modified unless you are confident the change is absolutely necessary.


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 all of the above enabled and configured, the OpenAI Provider can be used for all of 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.

Settings to generate text in OpenAI
Settings to generate image in OpenAI