Shows the usage of the OpenAI API. Sends an example request with the entered prompt.
Shows the integration of the OpenAI API. (TYPO3 CMS)
Adds a plugin to send a prompt to the OpenAI API and displays the generated answer.
Add via composer:
composer require "passionweb/open-ai-api"
- Install the extension via composer
- Flush TYPO3 and PHP Cache
This example uses the OpenAI API.
There are the following extension settings available.
# cat=API Key; type=string; label=OpenAI Secret Key openAiApiKey = YOUR_API_KEY
Enter your generated OpenAI API key.
# cat=basic request settings; type=string; label=OpenAI Model openAiModel = gpt-3.5-turbo
The id of the model which will generate the completion. See models overview for an overview of available models.
# cat=basic request settings; type=double+; label=OpenAI Temperature openAiTemperature = 0.5
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
# cat=basic request settings; type=int+; label=OpenAI Max-Tokens openAiMaxTokens = 275
The token (what are tokens and how to count them) count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).
# cat=basic request settings; type=int+; label=OpenAI Top-P openAiTopP = 1
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
# cat=basic request settings; type=double; label=OpenAI Frequency Penalty openAiFrequencyPenalty = 0.8
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
# cat=basic request settings; type=double; label=OpenAI Presence Penalty openAiPresencePenalty = 0
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
If something does not work as expected take a look at the log file.
Every problem is logged to the TYPO3 log (normally found in
I'm grateful for any feedback! Be it suggestions for improvement, requests or just a (constructive) feedback on how good or crappy this snippet/repo is.