PHPackages                             llmesh/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. llmesh/core

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

llmesh/core
===========

LLMesh Core - A flexible PHP SDK for interacting with multiple LLM providers

21PHPCI passing

Since Jun 7Pushed 1mo agoCompare

[ Source](https://github.com/fyunusa/llmesh)[ Packagist](https://packagist.org/packages/llmesh/core)[ RSS](/packages/llmesh-core/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

LLMesh
======

[](#llmesh)

[![Latest Stable Version](https://camo.githubusercontent.com/b097f70b377ea0039ba2cca0f632d045663bfa4c34877888cbe4004ad595ca5b/68747470733a2f2f706f7365722e707567782e6f72672f6c6c6d6573682f636f72652f76)](https://packagist.org/packages/llmesh/core)[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://packagist.org/packages/llmesh/core)[![Laravel Supported](https://camo.githubusercontent.com/ab2fb6918da8e2811897a1bccca2cfddf2c020908a7c49666428f549c9899862/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d737570706f727465642d627269676874677265656e2e737667)](https://packagist.org/packages/llmesh/laravel)[![OpenAI Supported](https://camo.githubusercontent.com/0e728e86843e341dd5de5bdc0bb1e448548e0905e79ca33cebd235c3182a0df5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f70656e41492d737570706f727465642d707572706c652e737667)](https://packagist.org/packages/llmesh/openai)[![Claude Supported](https://camo.githubusercontent.com/de6cd0656662cd016aeccf84e43d4088291ae90323d58d28b7d357cf4eff4283/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436c617564652d737570706f727465642d7265642e737667)](https://packagist.org/packages/llmesh/anthropic)[![Structured Extraction](https://camo.githubusercontent.com/f283b1d09c482fb8f7ed92280b961ab89dcd93dc07958e6634dc3472c3d5f286/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374727563747572656425323045787472616374696f6e2d507964616e7469632d2d7374796c652d626c75652e737667)](#structured-extraction)[![Tests](https://github.com/fyunusa/llmesh/actions/workflows/tests.yml/badge.svg)](https://github.com/fyunusa/llmesh/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

LLMesh is a flexible PHP SDK designed to help developers build AI-powered applications and autonomous agents.

---

Why use LLMesh?
---------------

[](#why-use-llmesh)

Integrating large language models (LLMs) into applications is complicated and heavily dependent on the specific model provider you use.

LLMesh standardizes integrating artificial intelligence (AI) models across supported providers. This enables developers to focus on building great AI applications, not waste time on technical details.

For example, here’s how you can generate text with various models using LLMesh:

```
use LLMesh\Core\LLMesh;
use LLMesh\Core\Generators\GenerateTextOptions;
use LLMesh\OpenAI\OpenAIProvider;

$response = LLMesh::generateText(
    new OpenAIProvider($apiKey),
    GenerateTextOptions::make()->withPrompt('What is love?')
);

echo $response->getText();
```

---

Installation
------------

[](#installation)

Install the core library along with a provider (e.g. OpenAI):

```
composer require llmesh/core llmesh/openai
```

---

Decoupled Packages
------------------

[](#decoupled-packages)

The LLMesh ecosystem consists of separate, modular packages:

- **[LLMesh Core](https://github.com/fyunusa/llmesh)**: The unified interfaces, memory builder, RAG pipeline, and orchestration loop.
- **[OpenAI Provider](https://github.com/fyunusa/llmesh-openai)**: Provider adapter for OpenAI models.
- **[Anthropic Provider](https://github.com/fyunusa/llmesh-anthropic)**: Provider adapter for Anthropic Claude models.
- **[Laravel Adapter](https://github.com/fyunusa/llmesh-laravel)**: First-class integration for Laravel applications.

---

Features
--------

[](#features)

- **[generateText](docs/generators.md)**: Unified API for text generation with full parameter customization.
- **[streamText](docs/streaming.md)**: Real-time chunked text generation and Server-Sent Events (SSE) responses.
- **[generateObject](docs/structured-output.md)**: Type-safe JSON output validated against custom schemas.
- **[Structured Extraction](docs/structured-extraction.md)**: Pydantic-style structured data extraction into fully typed PHP model classes.
- **[tools](docs/tools.md)**: Native function/tool calling with parameter mapping and validation.
- **[agents](docs/agents.md)**: Autonomous multi-step orchestration loop with tool execution.
- **[memory](docs/memory.md)**: Pluggable conversation memory stores (In-Memory, Redis, Database).
- **[RAG](docs/rag.md)**: End-to-end ingestion pipeline (load, split, embed, store, retrieve).

---

Structured Extraction
---------------------

[](#structured-extraction)

LLMesh supports Pydantic-style structured extraction, allowing you to define a PHP class to serve as the JSON schema, validation rules, and typed data container all in a single step.

```
use LLMesh\Core\LLMesh;
use LLMesh\Core\Structured\LLMModel;
use LLMesh\Core\Structured\Attributes\Field;
use LLMesh\Core\Structured\Attributes\Description;
use LLMesh\OpenAI\OpenAIProvider;

#[Description("An invoice extracted from a text document")]
class Invoice extends LLMModel
{
    public function __construct(
        #[Field(description: "The reference invoice number", example: "INV-1001")]
        public readonly string $invoiceNumber,

        #[Field(description: "Total invoice amount in USD", minimum: 0)]
        public readonly float $totalAmount,

        #[Field(description: "Payment due date")]
        public readonly \DateTimeImmutable $dueDate,
    ) {}

    public function validate(): void
    {
        if ($this->totalAmount < 0) {
            throw new \InvalidArgumentException("Invoice amount cannot be negative.");
        }
    }
}

// 1-line extraction directly into typed PHP object
$invoice = LLMesh::make()->extractFrom(
    Invoice::class,
    "Invoice INV-1001 details: Total $150.00, due on 2026-06-30.",
    new OpenAIProvider($apiKey)
);

echo $invoice->invoiceNumber;             // string: "INV-1001"
echo $invoice->totalAmount;               // float: 150.0
echo $invoice->dueDate->format('Y-m-d');  // DateTimeImmutable: "2026-06-30"
```

The system automatically handles JSON Schema generation, LLM invocation, self-correction/retries, post-deserialization validation, and type-coercion (converting string inputs to `DateTimeImmutable` instances, `BackedEnum` cases, floats, booleans, and nested model hierarchies).

---

Contributing
------------

[](#contributing)

Please see the [CONTRIBUTING.md](CONTRIBUTING.md) guide for information on local setup, extending LLMesh with custom providers or vector stores, and the pull request checklist.

---

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for details.

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance60

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d27bbaedbcc98c183b40947c384ccd1dbc906ea58a4f359eff58165b98393f39?d=identicon)[fyunusa](/maintainers/fyunusa)

---

Top Contributors

[![fyunusa](https://avatars.githubusercontent.com/u/55334829?v=4)](https://github.com/fyunusa "fyunusa (27 commits)")

### Embed Badge

![Health badge](/badges/llmesh-core/health.svg)

```
[![Health](https://phpackages.com/badges/llmesh-core/health.svg)](https://phpackages.com/packages/llmesh-core)
```

###  Alternatives

[chrisguitarguy/request-id-bundle

Add request IDs to to your Symfony requests.

451.5M6](/packages/chrisguitarguy-request-id-bundle)[edofre/yii2-fullcalendar-scheduler

Yii2 widget for fullcalendar scheduler module

2438.0k](/packages/edofre-yii2-fullcalendar-scheduler)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
