MIP is a powerful and flexible integration platform that allows seamless connections with OpenAI APIs. In this guide, we will walk through the process of integrating MIP with OpenAI API step by step.
1. Creating a Package and Flow in MIP
First, we start by creating a package and flow in the MIP platform.


Then open the integration flow. Click the button in the upper left corner to add a new flow configuration.

2. Defining the OpenAI API Key
We define a variable to securely store the OpenAI API key:
- Variable Name: openai_api_key
- Description: The API key is required for OpenAI access.
This approach ensures that when moving from a test environment to production, we only need to update this variable’s value.

3. Configuring the Integration
After saving the configuration, we move to the design screen, where we are greeted by the Start Connector. This connector helps define the protocol that will trigger the integration.
- Protocol: REST
- Endpoint: The address where the integration will be provided.
- Synchronous Option: If we expect synchronous responses from OpenAI, we must select Synchronous Endpoint.


4. Setting Up OpenAI API Requirements
a) Configuring Headers
Next, we add the Tools -> Transformations -> Set Context connector to define the HTTP headers required by the OpenAI API.


b) Making API Calls Using HTTP Connector
Then, we add the Tools > External Calls -> Technology > HTTP connector to connect with OpenAI API.
- HTTP Method: POST
- Endpoint: The API URL provided by OpenAI
- Timeout Setting: Since OpenAI requests can take time, we set a high timeout value.

You can find available endpoints under the Capabilities section in OpenAI Documentation.
c) Completing the Integration
To finalize the integration design, we add the End Connector. Once everything is set, click Save and Deploy.

5. Testing the Integration
To verify the integration, go to Operations > Endpoints and locate the endpoint URL we configured earlier.

Then, we use Postman to test the integration:
1. Create a new request.
2. Select POST as the method.
3. Enter MIP user credentials under the Authorization tab.

4. Paste the OpenAI request body in the Body section:
{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “developer”,
“content”: “Convert today’s top 10 rising US stocks to XML format and provide only the XML content, no comments.”
}
]
}
5. Send the request and examine the response from OpenAI.

6. Converting OpenAI Response to XML Format
To further improve our integration, let’s transform the OpenAI JSON response into XML format.
- Add a Set Context Connector.
- In the Context Properties tab, define a new variable to extract only the content field from the OpenAI JSON response.

3. Go to the Change Context tab and map this variable to the response.

4. Add a content-type header with application/xml in the Context Header section.

When you test the integration again using Postman, you will now see an XML response.

7. Monitoring Integration Logs
To analyze the integration process in detail:
- Go to Operations > Endpoints and change the Log Level to All Steps.

2. Send another request via Postman.
3. Navigate to Monitoring > Message Monitoring to view integration messages.

4. Click on the number under the Successful column
5. In the latest message, click Action > Show Full Log.
This opens a new window displaying the integration design, allowing you to track each step of the process. For example, after receiving a response from OpenAI, you can see how the Set Context step modifies the output.

In this guide, we explored how to integrate MIP with OpenAI APIs and configure the necessary settings. If you have any questions, feel free to reach out!