PHPackages                             saarnilauri/ai-provider-for-mistral - 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. saarnilauri/ai-provider-for-mistral

ActiveWordpress-plugin[Utility &amp; Helpers](/categories/utility)

saarnilauri/ai-provider-for-mistral
===================================

Independent WordPress AI Client provider for Mistral. Works as both a Composer package and WordPress plugin.

v1.1.1(1mo ago)622GPL-2.0-or-laterPHPPHP &gt;=7.4

Since Feb 10Pushed 1mo agoCompare

[ Source](https://github.com/saarnilauri/ai-provider-for-mistral)[ Packagist](https://packagist.org/packages/saarnilauri/ai-provider-for-mistral)[ Docs](https://github.com/saarnilauri/ai-provider-for-mistral)[ RSS](/packages/saarnilauri-ai-provider-for-mistral/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (18)Used By (0)

AI Provider for Mistral
=======================

[](#ai-provider-for-mistral)

A third-party provider for [Mistral](https://mistral.ai/) in the [PHP AI Client](https://github.com/WordPress/php-ai-client) SDK. Works as both a Composer package and a WordPress plugin.

This project is independent and is not affiliated with, endorsed by, or sponsored by Mistral AI.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- [wordpress/php-ai-client](https://github.com/WordPress/php-ai-client) must be installed

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

[](#installation)

### As a Composer Package

[](#as-a-composer-package)

```
composer require saarnilauri/ai-provider-for-mistral
```

The Composer distribution is intended for library usage and excludes `ai-provider-for-mistral.php`.

### As a WordPress Plugin

[](#as-a-wordpress-plugin)

1. Download `ai-provider-for-mistral.zip` from [GitHub Releases](https://github.com/saarnilauri/ai-provider-for-mistral/releases) (do not use GitHub "Source code" archives)
2. Upload the ZIP in WordPress admin via Plugins &gt; Add New Plugin &gt; Upload Plugin
3. Ensure the PHP AI Client plugin is installed and activated
4. Activate the plugin through the WordPress admin

#### Installing with WP-CLI

[](#installing-with-wp-cli)

Use the release ZIP URL from GitHub Releases — **not** the auto-generated `main.zip` source archive, which is missing the bundled dependencies:

```
wp plugin install https://github.com/saarnilauri/ai-provider-for-mistral/releases/download/v1.0.1/ai-provider-for-mistral.zip --activate
```

Replace `v1.0.1` with the desired release tag.

Building the Plugin ZIP
-----------------------

[](#building-the-plugin-zip)

Build a distributable plugin archive locally:

```
make dist
# or:
./scripts/build-plugin-zip.sh
```

The ZIP is created at `dist/ai-provider-for-mistral.zip` and includes `ai-provider-for-mistral.php`.

Testing
-------

[](#testing)

Install development dependencies:

```
composer install
```

Run unit tests:

```
composer test
# or:
composer test:unit
```

Run integration tests (requires `MISTRAL_API_KEY`):

```
composer test:integration
```

Release Workflow
----------------

[](#release-workflow)

This repository includes a GitHub Actions workflow at `.github/workflows/release-plugin-zip.yml`:

- On tag pushes matching `v*`, it builds `dist/ai-provider-for-mistral.zip`
- For tagged releases, it derives the version from the tag (for example `v0.1.0` -&gt; `0.1.0`) and validates committed metadata:
    - `readme.txt` `Stable tag` must match the tag version
    - `ai-provider-for-mistral.php` `Version` must match the tag version
- If versions do not match, the workflow fails
- It uploads the ZIP as a workflow artifact
- It attaches the ZIP to the GitHub release for that tag

Usage
-----

[](#usage)

### With WordPress

[](#with-wordpress)

The provider automatically registers itself with the PHP AI Client on the `init` hook. Simply ensure both plugins are active and configure your API key:

```
// Set your Mistral API key (or use the MISTRAL_API_KEY environment variable)
putenv('MISTRAL_API_KEY=your-api-key');

// Use the provider
$result = AiClient::prompt('Hello, world!')
    ->usingProvider('mistral')
    ->generateTextResult();
```

### As a Standalone Package

[](#as-a-standalone-package)

```
use WordPress\AiClient\AiClient;
use SaarniLauri\AiProviderForMistral\Provider\ProviderForMistral;

// Register the provider
$registry = AiClient::defaultRegistry();
$registry->registerProvider(ProviderForMistral::class);

// Set your API key
putenv('MISTRAL_API_KEY=your-api-key');

// Generate text
$result = AiClient::prompt('Explain quantum computing')
    ->usingProvider('mistral')
    ->generateTextResult();

echo $result->toText();
```

### Image Generation

[](#image-generation)

Mistral supports image generation through its [Agents API](https://docs.mistral.ai/agents/tools/built-in/image_generation). The provider handles the multi-step flow (agent creation, conversation, file download) automatically:

```
$result = AiClient::prompt('A red apple on a white background')
    ->usingProvider('mistral')
    ->generateImageResult();

// Get the generated image as base64-encoded PNG
$file = $result->getCandidates()[0]->getMessage()->getParts()[0]->getFile();
$binaryData = base64_decode($file->getBase64Data(), true);
file_put_contents('apple.png', $binaryData);
```

Supported Models
----------------

[](#supported-models)

Available models are dynamically discovered from the Mistral API. This includes text models and, for compatible models, vision and function-calling capabilities. Image generation is supported through models like `mistral-medium-2505`. See the [Mistral documentation](https://docs.mistral.ai/) for the full list of available models.

Configuration
-------------

[](#configuration)

The provider uses the `MISTRAL_API_KEY` environment variable for authentication. You can set this in your environment or via PHP:

```
putenv('MISTRAL_API_KEY=your-api-key');
```

External Services
-----------------

[](#external-services)

This plugin connects to the [Mistral AI API](https://api.mistral.ai/v1) to provide AI text generation and image generation capabilities.

Data is sent to the Mistral API when your application code makes AI generation requests through the PHP AI Client. The data sent includes your prompts, model configuration, and API key. No data is sent automatically — requests only occur when explicitly triggered by code using the PHP AI Client SDK.

This service is provided by [Mistral AI](https://mistral.ai/):

- [Terms of Service](https://mistral.ai/terms/)
- [Privacy Policy](https://mistral.ai/terms/#privacy-policy)

License
-------

[](#license)

GPL-2.0-or-later

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~3 days

Total

14

Last Release

42d ago

Major Versions

v0.3.3 → v1.0.02026-02-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/79a199c915de8587d998c6f52b3b46e89ff75eeb3d5a940498d4acac02f61f97?d=identicon)[saarnilauri](/maintainers/saarnilauri)

---

Top Contributors

[![saarnilauri](https://avatars.githubusercontent.com/u/36833033?v=4)](https://github.com/saarnilauri "saarnilauri (59 commits)")

---

Tags

wordpressaiconnectorllmmistral

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/saarnilauri-ai-provider-for-mistral/health.svg)

```
[![Health](https://phpackages.com/badges/saarnilauri-ai-provider-for-mistral/health.svg)](https://phpackages.com/packages/saarnilauri-ai-provider-for-mistral)
```

###  Alternatives

[ardagnsrn/ollama-php

This is a PHP library for Ollama. Ollama is an open-source project that serves as a powerful and user-friendly platform for running LLMs on your local machine. It acts as a bridge between the complexities of LLM technology and the desire for an accessible and customizable AI experience.

20755.8k](/packages/ardagnsrn-ollama-php)[soukicz/llm

LLM client with support for cache, tools and async requests

445.6k](/packages/soukicz-llm)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)

PHPackages © 2026

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