Introducing Agaip: The Next-Generation Agentic AI Framework

Bayram EKER
5 min read3 days ago

--

Welcome to Agaip — a cutting-edge, open-source framework engineered to bring Artificial Intelligence, dynamic model integration, and agentic behavior to any system effortlessly. Whether you’re working with Java (Spring Boot), Python (Django/Flask), PHP (Laravel), Go, or any other platform, Agaip’s API-driven, asynchronous design makes it the perfect solution for modern AI integration.

What Is Agaip?

Agaip is an API-first microservice designed to power your applications with AI and agentic capabilities. Here’s what sets it apart:

  • API-First Architecture:
    Built with FastAPI, Agaip exposes a robust RESTful API (with optional gRPC endpoints) that is fully documented via OpenAPI/Swagger. This means you can integrate it with any technology stack that supports HTTP calls.
  • Dynamic Plugin & Agent Management:
    Implement your AI models and agentic behaviors as modular plugins. New plugins can be added or updated dynamically, without needing to restart your entire system.
  • Asynchronous Task Processing:
    Leveraging Python’s async/await, Agaip handles tasks in a non-blocking manner, ensuring high performance and scalability even under heavy loads.
  • Built-In Database Integration:
    Every task is recorded using Tortoise ORM (defaulting to SQLite, with easy support for PostgreSQL or MySQL), offering a complete audit trail for monitoring and debugging.
  • DevOps-Ready:
    With an included Dockerfile and Kubernetes YAML configurations, Agaip is prepared for both local development and scalable production deployments.
  • Multi-Language Compatibility:
    Thanks to its API-centric design, any language — from Java and PHP to Go and Python — can consume Agaip’s endpoints, ensuring seamless integration across diverse environments.

How Does Agaip Work?

1. API Gateway

At the core, Agaip uses FastAPI to serve as the API gateway. This module handles security, routing, and logging. For example, here’s how you might define an endpoint to submit a task:

@app.post("/agent/task", summary="Submit a task to an agent", response_model=dict)
async def send_task(task: TaskRequest, token: str = Depends(verify_token)):
result = await agent_manager.dispatch_task(task.agent_id, task.payload)
return result

2. Agent Manager

The Agent Manager is responsible for dynamically loading agents and dispatching tasks. Agents use plugins — each representing an AI model or behavior — to process tasks asynchronously. Consider this snippet:

class AgentManager:
def __init__(self):
self.agents: Dict[str, Agent] = {}

async def register_agent(self, agent_id: str, plugin_path: str) -> None:
plugin_class = load_plugin(plugin_path)
plugin_instance = plugin_class()
await plugin_instance.load_model()
self.agents[agent_id] = Agent(agent_id, plugin_instance)

async def dispatch_task(self, agent_id: str, task_data: Dict) -> Dict:
if agent_id not in self.agents:
return {"error": f"Agent '{agent_id}' not found."}
task_record = await Task.create(
agent_id=agent_id,
payload=task_data,
status="processing"
)
result = await self.agents[agent_id].process_task(task_data)
task_record.result = result
task_record.status = "completed"
await task_record.save()
return result

3. Dynamic Plugin Loader

Agaip leverages a dynamic plugin loader to import AI models at runtime. This design enables seamless extension and customization:

def load_plugin(plugin_path: str):
module_name, class_name = plugin_path.rsplit(".", 1)
module = importlib.import_module(module_name)
return getattr(module, class_name)

4. Sample Plugin Implementation

Here’s an example of a dummy AI model plugin that simulates processing:

from agaip.plugins.base_model import BaseModelPlugin
import asyncio

class DummyModelPlugin(BaseModelPlugin):
def __init__(self):
self.model = None

async def load_model(self) -> None:
await asyncio.sleep(0.1) # Simulate model loading time
self.model = "dummy_model_loaded"

async def predict(self, input_data: dict) -> dict:
await asyncio.sleep(0.1) # Simulate processing time
return {
"status": "success",
"model": self.model,
"input": input_data,
"result": "dummy_prediction"
}

5. Database Integration

All tasks processed by Agaip are stored in a database using Tortoise ORM. Here’s a simplified model:

from tortoise import fields, models

class Task(models.Model):
id = fields.IntField(pk=True)
agent_id = fields.CharField(max_length=50)
payload = fields.JSONField()
result = fields.JSONField(null=True)
status = fields.CharField(max_length=20, default="pending")
created_at = fields.DatetimeField(auto_now_add=True)
updated_at = fields.DatetimeField(auto_now=True)

Integration Across Different Languages

Agaip’s API-centric design makes it language agnostic. Here’s how you can connect to Agaip from various environments:

Java (Spring Boot)

@FeignClient(name = "agaipClient", url = "http://agaip-service")
public interface AgaipClient {
@PostMapping("/agent/task")
ResponseEntity<Map<String, Object>> sendTask(@RequestBody TaskRequest taskRequest,
@RequestHeader("Authorization") String token);
}

Python (Django/Flask)

import requests

headers = {"Authorization": "Bearer gecerli_token"}
payload = {"agent_id": "agent_1", "payload": {"data": "example data"}}
response = requests.post("http://agaip-service/agent/task", json=payload, headers=headers)
print(response.json())

PHP (Laravel)

$client = new \GuzzleHttp\Client();
$response = $client->post('http://agaip-service/agent/task', [
'headers' => [
'Authorization' => 'Bearer gecerli_token',
'Accept' => 'application/json',
],
'json' => [
'agent_id' => 'agent_1',
'payload' => ['data' => 'example data'],
],
]);
$result = json_decode($response->getBody(), true);
print_r($result);

Go

package main

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)

type TaskRequest struct {
AgentID string `json:"agent_id"`
Payload map[string]interface{} `json:"payload"`
}

func main() {
reqBody := TaskRequest{
AgentID: "agent_1",
Payload: map[string]interface{}{"data": "example data"},
}
jsonData, _ := json.Marshal(reqBody)
req, _ := http.NewRequest("POST", "http://agaip-service/agent/task", bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer gecerli_token")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Status:", resp.Status)
// Process the response as needed...
}

Benefits of Using Agaip

  • Unified AI Integration:
    Leverage a single API to integrate diverse AI models and agentic behaviors into your systems.
  • Flexibility:
    Easily add, update, or swap out AI modules without system downtime.
  • Scalability:
    Asynchronous processing and containerized deployments ensure that Agaip can scale to meet the demands of high-traffic environments.
  • Cross-Platform Support:
    With client SDKs possible for any language, you’re not locked into one ecosystem.
  • Rapid Prototyping:
    Hot-reloading and interactive API documentation allow for quick iterations and testing.

Future Enhancements and Roadmap

Agaip is in its early stages, and we’re excited about its potential. Here are some of the future directions we plan to explore:

  • Advanced Security:
    Integrate robust authentication mechanisms like JWT or OAuth2.
  • Enhanced Monitoring & Logging:
    Build in support for centralized logging (using ELK) and monitoring (with Prometheus/Grafana) to track performance and detect issues in real time.
  • gRPC Support:
    Offer gRPC endpoints for environments where low latency and high performance are paramount.
  • Extended Database Options:
    Provide out-of-the-box configurations for PostgreSQL, MySQL, and other enterprise-grade databases.
  • Message Queue Integration:
    Explore integrating RabbitMQ, Kafka, or Celery to handle distributed processing and complex task queuing.
  • Community-Driven Plugins:
    Encourage contributions from the community to build a library of plugins tailored for different industries — from finance and healthcare to IoT and smart devices.
  • Comprehensive SDKs:
    Develop and maintain client SDKs in multiple languages to simplify integration and accelerate adoption.

Get Involved!

Agaip is an evolving project, and its future is driven by community contributions. We welcome developers, researchers, and AI enthusiasts to:

  • Explore the Code: Visit the repository on GitHub at https://github.com/bayrameker/agaip.
  • Contribute: Open issues, submit pull requests, and share your ideas for new features or improvements.
  • Integrate: Try Agaip in your projects and share your feedback — let’s shape the future of AI integration together!

Conclusion

Agaip is a new, versatile framework designed to integrate AI, dynamic models, and agentic behaviors into any system, regardless of the underlying technology stack. Its modern, API-first approach, combined with asynchronous processing and containerized deployment, makes it ideal for both rapid prototyping and production-scale applications.

We’re excited to see how the community will use and enhance Agaip. Join us on this journey, and help make AI integration simpler, faster, and more powerful.

Happy coding, and welcome to the future of agentic AI with Agaip!

Feel free to fork the repository, open issues, or submit pull requests on GitHub:
https://github.com/bayrameker/agaip

--

--

No responses yet