Build an AI Agent
- Time: Under 10 minutes
- What you'll build: An AI agent that connects to an LLM, uses tools, and responds to user queries in chat.
An AI agent uses an LLM to reason about user queries and call tools to retrieve information or perform actions. This quick start shows the full cycle: create a project, add an AI Chat Agent artifact, configure its instructions, and test it in the built-in chat panel.
Prerequisites
A working Choreo Integrator environment.
- Choreo Cloud setup: Sign up and launch Choreo Integrator in the browser-based cloud editor.
Step 1: Create the integration
-
On the project overview page, click Open Cloud Editor.

-
The Choreo Integrator cloud editor opens in your browser.

The cloud editor creates a default integration for you, so you don't need to name it now. You can change its name when you deploy it. For more information, see Save and deploy.
Step 2: Add an AI chat agent
-
In the design view, click Add Artifact manually.

-
Select Chat Agent Service under AI Integration.

-
The Create Chat Agent Service form opens. Set Role to
ChoreoIntegratorAssistant. -
Set Instructions to:
You are a highly skilled Choreo Integration Architect. Your goal is to assist developers in building, debugging, and optimizing integration flows.
-
Leave the remaining configuration fields at their default values.
-
Scroll down to Advanced Configurations at the bottom of the form, and set Agent Name to
ChoreoIntegratorAssistant. -
Click Create.

By default, the agent is configured to use the Default Choreo Model Provider. If you want to use a different LLM, see Model providers for the full list of supported providers (OpenAI, Azure OpenAI, Anthropic, and others).
If you are using the Default Choreo Model Provider, the access token is obtained through Choreo Integrator Copilot. If you have not already signed in, you will be prompted to do so.
Step 3: Run and test
-
Click Run.
-
Click Test in the pop-up. The chat panel opens.
-
Type
Helloto check that the agent replies.
Step 4: Deploy to Choreo Cloud
To deploy your integration to Choreo Cloud from the cloud editor, see Save and deploy.
Rather not build it yourself? Deploy the AI Chat Agent sample straight to Choreo Cloud. See Start with sample integrations.
Source code
View the generated Ballerina code
The steps above generate two files: agents.bal for the agent definition and main.bal for the listener and service.
agents.bal
import ballerina/ai;
final ai:Agent choreoIntegratorAssistantAgent = check new (
systemPrompt = {
role: string `ChoreoIntegratorAssistant`,
instructions: string `You are a highly skilled Choreo Integration Architect. Your goal is to assist developers in building, debugging, and optimizing integration flows.`
},
model = wso2ModelProvider,
tools = []
);
main.bal
import ballerina/ai;
import ballerina/http;
listener ai:Listener chatAgentListener = new (listenOn = check http:getDefaultListener());
service /choreoIntegratorAssistant on chatAgentListener {
resource function post chat(@http:Payload ai:ChatReqMessage request) returns ai:ChatRespMessage|error {
string stringResult = check choreoIntegratorAssistantAgent.run(request.message, request.sessionId);
return {message: stringResult};
}
}
Was this page helpful?