Download the PHP package raulast/macro-llm-php without Composer

On this page you can find all versions of the php package raulast/macro-llm-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package macro-llm-php

macro-llm-php

Provider-agnostic AI client for Laravel, Slim 4, and standalone PHP.

PHP Version Laravel Packagist

Overview

MacroLLM provides a unified interface to interact with any AI provider from any PHP 8.1+ application. Call $llm->chat(...) with the same request format regardless of which provider is behind the call — swap providers by changing a single string.

Internally, every request and response flows through a normalized format (InternalRequest / InternalResponse). Providers implement bidirectional normalization: your application code stays the same. This decouples business logic from vendor-specific APIs and makes provider migration a configuration change, not a rewrite.

The HTTP layer is a thin Guzzle wrapper (HttpClient) — illuminate/http is only pulled in for Laravel macro registration, not for core HTTP operations. Standalone and Slim users get zero Laravel overhead.

On top of the provider layer, MacroLLM provides a full agentic stack: Skills (reusable system-prompt + tool bundles), Agents (automatic tool-call loops with configurable memory), and Orchestration (sequential or parallel multi-agent workflows). Combined with built-in MCP client/server support, you can build complex AI-powered systems while keeping each piece testable and swappable.

Features

Supported Providers

Provider chat embed image TTS STT rerank
openai ✅ ✅ ✅ ✅ ✅ —
anthropic ✅ — — — — —
gemini ✅ ✅ ✅ — — —
groq ✅ — — — ✅ —
openrouter ✅ ✅ — — — —
ollama ✅ ✅ — — — —
llamacpp ✅ ✅ — — — —
mistral ✅ ✅ — — ✅ —
deepseek ✅ — — — — —
xai ✅ ✅ ✅ — — —
azure ✅ ✅ ✅ — — —
cohere ✅ ✅ — — — ✅
elevenlabs — — — ✅ — —
opencode-zen-go ✅ — — — — —
opencode-zen-go-anthropic ✅ — — — — —

Capabilities are declared via interfaces. Use instanceof to check at runtime:

Provider Details

Provider Type Auth Default Base URL Notes
openai OpenAI-compatible Bearer API key api.openai.com/v1 Also supports Azure OpenAI via base_url override
anthropic Native x-api-key header api.anthropic.com/v1 Messages API
gemini Native x-goog-api-key header generativelanguage.googleapis.com/v1beta generateContent API
groq OpenAI-compatible Bearer API key api.groq.com/openai/v1
openrouter OpenAI-compatible Bearer API key openrouter.ai/api/v1 Model names prefixed: openai/gpt-4o
ollama OpenAI-compatible Optional localhost:11434/v1 Local inference
llamacpp OpenAI-compatible None localhost:8080/v1 Local inference
opencode-zen-go OpenAI-compatible Bearer API key opencode.ai GLM, Kimi, DeepSeek, MiMo; API key from opencode.ai Zen console
opencode-zen-go-anthropic Anthropic-compatible x-api-key header opencode.ai MiniMax, Qwen; same API key as opencode-zen-go
azure OpenAI-compatible api-key header {resource}.openai.azure.com/openai/deployments/{deployment} Resource/deployment/version via extra_headers
mistral OpenAI-compatible Bearer API key api.mistral.ai/v1
deepseek OpenAI-compatible Bearer API key api.deepseek.com/v1 Static model list
xai OpenAI-compatible Bearer API key api.x.ai/v1
cohere Native Bearer API key api.cohere.com/v2 Native /v2/chat; streaming SSE

Requirements

Installation

Laravel auto-discovery registers the ServiceProvider automatically. Optionally publish the config:

Configuration

The config file (config/macro-llm.php) defines:

Key Description Default
default_provider Provider used when none is specified ollama
timeout Global request timeout in seconds 30
retries Automatic retries on failure (exponential backoff) 0
retry_delay_ms Base delay in ms for retry backoff (doubles each attempt) 500
max_tool_iterations Max agent tool-call loop iterations 10
providers Array of provider configurations —
mcp_servers External MCP server connections —

Each provider entry supports: api_key, default_model, base_url, timeout, retries, retry_delay_ms, extra_headers. All numeric fields are ?int — null means "use global value".

API keys and other string settings support environment variable patterns ('${ENV_VAR}'), expanded when the configuration object is built. Load your .env before constructing Config. A variable that is not defined is left verbatim rather than collapsing to an empty string, so a misconfiguration stays visible instead of turning into a confusing 401.

Example .env entries:

Usage

Standalone (no framework)

Laravel (via Facade)

Laravel (via HTTP macro)

Streaming

Listing Available Models

Tool Calling

Skills

Vision/Multimodal

Structured Output

Observe each event in the agent's tool-call loop without modifying or extending Agent (which is final). Pass an onStep closure to AgentConfig — it receives an AgentStep value object at every meaningful point in the loop.

Step types:

Type Fires when Populated fields
LlmResponse LLM responds with tool calls (loop continues) response
ToolCall Before a tool is executed toolCall
ToolResult After a tool finishes (success or error) toolCall, toolResult
FinalResponse LLM responds with no tool calls (loop exits) response

The callback is fire-and-forget: exceptions propagate to the run() caller. Passing null (the default) has zero overhead on the hot path.

Conversation Memory

Multi-Agent Orchestration

MCP Client

MCP Server (Laravel)

Slim 4

MacroLLMSlimExtension requires the container to support set(). PHP-DI's Container does. Slim's built-in container does not — use PHP-DI or another writable PSR-11 container.

The config/macro-llm.php file lives in your project (not in the package) and returns a plain array:

Same format as Config::fromArray() — see the Configuration section.

Directory Structure

Architecture

MacroLLM follows a hexagonal architecture. The core domain (Message, Contract, Registry) has no framework dependencies. The provider layer implements bidirectional normalization behind ProviderInterface, so adding a new provider means implementing a single class without touching application code. The agentic layer (Agent, Skill, Orchestration) composes on top of the provider layer, using the same normalized types. Framework integrations (Laravel, Slim) are thin adapters that wire the core into their respective DI containers and lifecycle hooks.

Exception Handling

Exception Thrown when
UnregisteredProviderException Macro called for unregistered provider
ProviderRequestException HTTP 4xx/5xx from provider API
MissingApiKeyException API key missing before request
ToolNotFoundException ToolRegistry::get() asked for a name that was never registered
MaxToolIterationsException Agent loop exceeded max iterations
SkillToolConflictException Two composed skills define same tool
SkillToolNotFoundException Skill references a tool not in the registry
MCPConnectionException MCP server unreachable
MCPToolCallException MCP server returned error
StreamInterruptedException SSE stream ended unexpectedly

An agent only executes the tools it was given — the ones resolved from its skills plus AgentConfig::tools. If a model names a tool outside that set, the agent does not throw: it returns a ToolResult in error state so the model can correct itself, and the loop continues. Tools passed through AgentConfig::tools do not need to be registered in the global ToolRegistry as well.

Testing

composer test runs the unit suite only: 225 tests backed by hand-authored fixtures, no network. It passes on a clean checkout with no credentials.

The integration suite exercises a locally running Ollama and self-skips when it is unreachable, so it never fails a machine that does not have it. Capabilities no local provider can serve — image generation, TTS, STT, reranking, and the provider-specific end-to-end paths — are present as explicitly skipped tests, so the coverage gap shows up in the output instead of being silently absent.

Note that the integration suite talks to real models and can take tens of minutes depending on the machine and which models are warm.

License

MIT — see LICENSE file.

Author

Raul Antonio Salazar Torres — [email protected]


All versions of macro-llm-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.0
guzzlehttp/promises Version ^2.0
nyholm/psr7 Version ^1.0
psr/container Version ^2.0
psr/http-message Version ^1.0|^2.0
psr/http-server-middleware Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package raulast/macro-llm-php contains the following files

Loading the files please wait ...