How to interact with OpenAI ChatGPT Through MuleSoft
Kancharla Sandeep Sai Kumar
{ "PartOf" : "Mule Mentor??","?Certified" : "??2 x MuleSoft ?", "service??" : "??REST API?soap??", "Expertise??" : "DataWeave", "???Developer" : "??Mulesoft", "???Trailhead": "??????Explorer" }
What does ChatGPT stand for?
The name ChatGPT stands for?Chat Generative Pre-trained Transformer. This latest GPT technology is based on a deep learning model that evaluates the importance of the words or phrases in each input.
What can ChatGPT do?
ChatGPT can?write silly poems and songs or quickly explain just about anything found on the internet.
Can we integrate chatGPT through MuleSoft?
Yes, we can integrate chatGPT with mulesoft, to do this follow the below steps
1.?Go to OpenAI - https://platform.openai.com/
2.?Click on profile?
3. Click on view API Key
4.?Click on create new security key
5. Once click on create new security key it will pop up new window with security key, so keep your secure key safely, if you lost the key generate new one
6. ?Open anypoint studio
7. Create a new project
8. Drag and drop the http listener connector
:::?add host as localhost
:::?port as 8081(user choice)
:::?path opeanAI(user choice)
9. then drag http request connector and config the details like below
config the request details to integrate with openAI
$OPENAI_API_KEY indicates the API Key which we earlier generated in point 5
Request URL:- https://api.openai.com/v1/chat/completions
Headers need to pass:-?
1. Authorization: Bearer $OPENAI_API_KEY
2. Content-Type: application/json
Body:-?
?{
? "model": "gpt-3.5-turbo",
? ? "messages": [
? ? ? ? {
? ? ? ? ? ? "role": "user",
? ? ? ? ? ? "content": "Hello!"
? ? ? ? }
? ? ]
}
10. add transform connector with value payload
11. deploy the mule application
12. once deployed hit the mule endpoint from postman according to your listener config details in my case (https://localhost:8081/opeanAI)
For more actions refer opeanAI api-reference documentation
2 x MuleSoft Certified || Mule 4.x || REST API || Mulesoft Developer at Prowess Software Services
1 年Thanks for sharing Kancharla Sandeep Sai Kumar such a good information ??
Mulesoft Developer
1 年Good information Kancharla Sandeep Sai Kumar
Thanks for sharing Kancharla Sandeep Sai Kumar. Great info.