How to interact with OpenAI ChatGPT Through MuleSoft

How to interact with OpenAI ChatGPT Through MuleSoft

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?

No alt text provided for this image

3. Click on view API Key

No alt text provided for this image

4.?Click on create new security key

No alt text provided for this image

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

No alt text provided for this image

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

Aparna Nalla

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 ??

要查看或添加评论,请登录

社区洞察

其他会员也浏览了