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.
// 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
Package
Role
UI
Providers
Tables
Bridge
Overview
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
The provider contract, the conversation store, tool calling and the MCP bridge — the machinery every AI feature relies on.
An abstract service (MelisAIEngineModelService) every provider implements: setClient, addToolsToPayload, sendCustomAI…
Keeps conversation state across multi-hop tool use.
Dispatches tool calls to MCP servers or built-in PHP functions, then continues.
Connect external MCP servers and expose their tools to agents.
User and context files turned into provider inputs (File API or embed).
Every call logged to melis_ai_daily_usage, feeding the usage dashboard.
See it in action
Implement a handful of abstract methods and the engine routes to your provider by the model’s company name.
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 … }
Implement the abstract contract — setClient, addToolsToPayload, sendCustomAI, token counters — and the engine routes to it by the model’s company name.
For developers
The base send() adds tools, appends content, calls sendCustomAI(), sets token counts, and returns a structured result.
Providers hold no tables — all state lives in the engine’s tables.
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
Melis AI Engine is the runtime — here are the modules around it.
See how generative and agentic AI runs across the platform.