AI EngineAI suite · runtime

The provider-agnostic AI runtime

Melis AI Engine is the engine room of Melis AI: the provider contract, the shared tables and conversation store, file ingestion, and the MCP / tool-calling bridge that every AI feature runs on.

Live demo
engine — AI runtime
// One chat turn, provider-agnostic:
// instance → agent → model → company → provider
$model  = $engine->getActiveModelClass();   // Claude | Gemini | …
$result = $model->send($contextArr);        // tools dispatched,
                                            // continued until done
// usage → melis_ai_daily_usage
// state → melis_ai_conversation_state
Tool callingMCP + local
Add a providerextends the contract

Package

melis-ai-engine

Role

AI runtime

UI

None — service

Providers

Pluggable

Tables

melis_ai_*

Bridge

MCP + tools

Overview

The runtime in one line

A chat turn resolves instance → agent → model, builds the context, and the provider’s send() / sendCustomAI() calls the API. Any tool calls are dispatched (MCP or built-in) and fed back, and it continues until the model is done — then usage is logged and conversation state stored.

It’s a developer layer with no menu of its own (the UI lives in Melis AI). To add a new provider — say OpenAI — create a module that extends MelisAIEngineModelService, implement the abstract methods, and route to it by the model’s company name. Claude and Gemini are the two reference implementations.

Key features

Everything an AI feature runs on

The provider contract, the conversation store, tool calling and the MCP bridge — the machinery every AI feature relies on.

The provider contract

An abstract service (MelisAIEngineModelService) every provider implements: setClient, addToolsToPayload, sendCustomAI…

Conversation store

Keeps conversation state across multi-hop tool use.

Tool / function calling

Dispatches tool calls to MCP servers or built-in PHP functions, then continues.

MCP bridge

Connect external MCP servers and expose their tools to agents.

File ingestion

User and context files turned into provider inputs (File API or embed).

Usage logging

Every call logged to melis_ai_daily_usage, feeding the usage dashboard.

See it in action

One contract, any provider

Implement a handful of abstract methods and the engine routes to your provider by the model’s company name.

engine — provider contract
abstract class MelisAIEngineModelService {
    abstract public function setClient();
    abstract public function addToolsToPayload($payload);
    abstract public function sendCustomAI(?array $payload = []): array;
    abstract public function getMessageKey(): string; // 'messages' | 'contents'
    // … token counters, file processing …
}
PluggableBy company name
Extend

Add a provider in a few methods

Implement the abstract contract — setClient, addToolsToPayload, sendCustomAI, token counters — and the engine routes to it by the model’s company name.

  • extends MelisAIEngineModelService
  • Claude & Gemini are the references
  • Routed by company name

For developers

How it's wired

Fixed lifecycle

The base send() adds tools, appends content, calls sendCustomAI(), sets token counts, and returns a structured result.

Stateless providers

Providers hold no tables — all state lives in the engine’s tables.

Company-based routing

getActiveModelClass() picks the provider from the model’s company name.

// The engine routes to a provider by the model's company:
$model = $engine->getActiveModelClass();   // company → Claude | Gemini
// send() returns: request, responseData, result, errors,
// needs_continuation, session_id, tool_results …

Part of Melis Platform

Explore the rest of the platform

Melis AI Engine is the runtime — here are the modules around it.

The runtime behind Melis AI

See how generative and agentic AI runs across the platform.