- Articles
- Building An Api With Ai Assisted Wso2 Mi Copilot
WSO2
Building an API with AI Assisted WSO2 MI Copilot
What if you could design and deploy complex API integrations simply by describing what you need in plain English? With the arrival of MI Copilot in the latest version of WSO2 Micro Integrator, that idea is now a reality. This article walks you through how to build an API using AI-assisted development directly within Visual Studio Code.
We’ll guide you step-by-step through setting up your environment, creating an API that converts XML to JSON and even handling errors and generating documentation, all with the help of natural language instructions.
Introducing MI Copilot
MI Copilot is an AI assistant built using generative AI technologies, tailored for use with the WSO2 Micro Integrator. It allows developers to define integration workflows using everyday language, which the assistant then translates into fully structured configurations.
Most importantly, MI Copilot ensures that WSO2 best practices are always followed while building the workflow based on the given requirements. Therefore, it helps someone new to WSO2, to use it as a learning tool, which provides a detailed explanation about the flow it creates and also alternative options based on WSO2 capabilities.
Use Case: Building an API flow using MI Copilot
Let’s walk through how to create a simple API flow in WSO2 Micro Integrator with the following functionalities.
- REST API accepts GET requests with the URL context “/ai-demo”.
- Invoke a backend which returns an XML response.
- Once the response is received, transform it to a JSON and send it back to the caller.
Setting Up your environment
Step 1: Installing the VS Code and Micro Integrator extension
In order to start using the AI features in Micro Integrator, first download and install the Visual Studio Code from: https://code.visualstudio.com/.
Step 2: Add the Micro Integrator Extension
From the Extensions panel in VS Code, search for “micro integrator” and install the official WSO2 Micro Integrator extension. Click on “Install” to install the extension.
After installation, you’ll find a new icon in the sidebar representing the Micro Integrator workspace.

Once installed, it will appear in the left toolbar with. Click the icon to see the new Micro Integrator developer workspace.

Create a new project
Click on the “Create New Project” button to initiate a new project with project location and name.

It will bring the project main page, with some templates on the bottom and the AI panel at the top.

Build the API using AI
Rather than creating the API from scratch or using a template, in this case, we will create it using the AI assisted development tool provided.
In order to create the API as per our requirement, copy and paste the below steps in the AI panel and click on “Generate”.
Create a REST API with following functionality.
- REST API accepts GET requests with the URL context “/ai-demo”.
- Invoke a backend which returns an XML response.
- Once the response is received, transform it to a JSON and send it back to the caller
Here’s how efficiently it generates the artifacts, along with explanations for each step. Once the artifacts are created, we can add them to the project and open them in the UI editor for further configuration.
▶ Video 1: Generating the API with MI Copilot
This video shows how the AI interprets the natural language request and automatically generates the required API components in seconds.
If we want to change any configuration, rather than configuring manually, we can ask the AI tool to configure it for us. For example, if we want to change the backend URL to “https://zo0vq.wiremockapi.cloud/xmljson/mock” here is how we can get it configured from the AI tool.
▶ Video 2: Updating the Backend URL Using AI
Watch how easily the backend service URL is changed by simply describing the update in plain English.
In order to test the API, click on the “Build and Run” icon in the top right corner. It will ask us to configure the WSO2 MI Runtime path and provide the location of the latest WSO2 MI 4.3.0 folder location in our local machine.
Once clicked, it will build and deploy the API in the Micro Integrator instance started within the editor itself. We can see the API deployment is happening in the console logs in the “OUTPUT” tab of the VS Code editor.

Then let's try to add error handling logic to the API in the same way as previous.
▶ Video 3: Adding Error Handling Logic
This video demonstrates how MI Copilot can insert error-handling mechanisms into your API configuration based on a simple user prompt.
More resources to the API with different methods like “POST,PUT,DELETE” can also be added using the MI Copilot.
▶ Video 4: Adding More Resources to the API
See how to extend the API with additional HTTP methods using MI Copilot, without needing to manually modify the configuration files.
Finally, the documentation for the API can be created using the MI Copilot by providing the request in natural language.
▶ Video 5: Creating API Documentation with MI Copilot
This video shows how MI Copilot generates human-readable documentation directly from your integration logic.
Conclusion
The introduction of MI Copilot, an AI-assisted development tool within the WSO2 Micro Integrator extension for Visual Studio Code, marks a significant advancement in how integration solutions are built. By allowing developers to describe their needs in natural language, MI Copilot generates integration flows in seconds using the correct syntax and consistently following WSO2 best practices.
This not only speeds up development but also provides a valuable learning experience. Developers gain insights into the recommended methods and components for building robust integrations across systems, helping them grow their expertise while delivering results faster.
In this article, we’ve demonstrated how MI Copilot simplifies API creation from defining flows and transforming data, to handling errors and generating documentation.
If you’re interested in exploring this technology further or considering WSO2 for your integration needs, don’t hesitate to reach out, our team is here to support your journey towards smarter and more efficient integration development.
Related Articles
Catch up on the latest news, articles, guides and opinions from Claria.