Skip to content

viplgoswami1/mulesoft-gemini-agentic-eapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MuleSoft Gemini Agentic EAPI

License MuleSoft Java Gemini

A MuleSoft Experience API that integrates with Google Gemini AI for Native Checkout Functionality. This eapi is direct plug-and-play app to enable UCP for any of the eCommerce application, enabling agentic AI capabilities within the Anypoint Platform ecosystem.


Overview

This API acts as an intelligent orchestration layer between enterprise systems and Google's Gemini AI, enabling:

  • Agentic workflows — AI-driven decision making within Mule flows
  • Natural language processing — Process unstructured data with Gemini
  • Enterprise integration — Connect Gemini AI to any backend system via MuleSoft

Architecture

Client Request
      ↓
MuleSoft Gemini Agentic EAPI
      ↓
Google Gemini AI API
      ↓
Response with AI-generated insights

Getting Started

Prerequisites

  • Anypoint Studio 7.15+
  • Mule Runtime 4.4.0+
  • Java 17
  • Google Cloud account with Gemini API access
  • Google Gemini API Key

Installation

  1. Clone the repository:
git clone https://github.com/viplgoswami1/mulesoft-gemini-agentic-eapi.git
cd mulesoft-gemini-agentic-eapi
  1. Import into Anypoint Studio:

    • FileImportAnypoint Studio Project from File System
    • Select the cloned folder
    • Click Finish
  2. Configure your credentials in src/main/resources/config.yaml:

gemini:
  api:
    key: "YOUR_GEMINI_API_KEY"
    url: "https://generativelanguage.googleapis.com/v1beta"
    model: "gemini-pro"

Configuration

Get a Gemini API Key

  1. Go to https://ai.google.dev
  2. Click Get API key in Google AI Studio
  3. Create a new API key
  4. Copy the key into your config

Environment Variables

Variable Description Required
GEMINI_API_KEY Google Gemini API key
GEMINI_MODEL Model name (default: gemini-pro)
GEMINI_MAX_TOKENS Max response tokens (default: 1024)

API Endpoints

POST /gemini/generate

Generate AI content using Gemini.

Request:

{
  "prompt": "Summarize the following product description for a Google Shopping listing",
  "context": "Your product description here...",
  "maxTokens": 500
}

Response:

{
  "generatedText": "AI-generated content here...",
  "model": "gemini-pro",
  "tokenCount": 245,
  "status": "SUCCESS"
}

POST /gemini/agent/execute

Execute an agentic workflow with multi-step reasoning.

Request:

{
  "task": "Analyze product catalog and suggest optimizations",
  "data": { ... },
  "steps": ["analyze", "recommend", "format"]
}

Example Mule Flow

<flow name="geminiAgenticFlow">
    <http:listener path="/gemini/generate" method="POST"/>
    
    <transform:message>
        <transform:set-payload><![CDATA[%dw 2.0
output application/json
---
{
    contents: [{
        parts: [{
            text: payload.prompt ++ "\n\n" ++ payload.context
        }]
    }]
}]]></transform:set-payload>
    </transform:message>
    
    <http:request 
        url="https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent"
        method="POST">
        <http:headers>
            <http:header key="x-goog-api-key" value="${gemini.api.key}"/>
        </http:headers>
    </http:request>
    
    <logger message="#[payload]"/>
</flow>

Also See


Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'feat: add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

License

Apache License 2.0 — see LICENSE for details.


Author

Viplove Goswami


Built with ❤️ for the MuleSoft and AI community