torounit / ai-provider-for-lm-studio
LM Studio AI Provider for the PHP AI Client SDK.
Package info
github.com/torounit/ai-provider-for-lm-studio
pkg:composer/torounit/ai-provider-for-lm-studio
0.1.0
2026-06-06 07:49 UTC
Requires
- php: >=7.4
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- phpcompatibility/php-compatibility: dev-develop
- phpstan/phpstan: ~2.1
- slevomat/coding-standard: ^8.20
- squizlabs/php_codesniffer: ^3.7 || ^4.0
- wordpress/php-ai-client: ^1.3 || dev-trunk
Suggests
- wordpress/php-ai-client: Required. The core PHP AI Client SDK that this provider extends.
README
LM Studio AI Provider for the PHP AI Client SDK.
Requirements
- PHP 7.4+
- wordpress/php-ai-client ^1.3
- LM Studio running locally with the server enabled
Installation
As a Composer Package
composer require torounit/ai-provider-for-lm-studio
As a WordPress Plugin
- Upload the plugin files to
/wp-content/plugins/ai-provider-for-lm-studio/ - Activate the plugin through the Plugins menu in WordPress
- Start LM Studio and enable the local server (Developer tab → Start Server)
Configuration
| Variable | Default | Description |
|---|---|---|
LM_STUDIO_SERVER_URL |
http://localhost:1234 |
LM Studio server URL (scheme + host + port, no API path) |
Both environment variables and PHP constants (e.g. define('LM_STUDIO_SERVER_URL', '...') in wp-config.php) are supported.
Usage
Composer (standalone)
<?php require __DIR__ . '/vendor/autoload.php'; use WordPress\AiClient\AiClient; use ToroUnit\LmStudioAiProvider\Provider\LmStudioProvider; // putenv('LM_STUDIO_SERVER_URL=http://localhost:1234'); $registry = AiClient::defaultRegistry(); $registry->registerProvider(LmStudioProvider::class); // List available models $models = LmStudioProvider::modelMetadataDirectory()->listModelMetadata(); foreach ($models as $model) { echo $model->getId() . "\n"; } // Generate text $result = AiClient::prompt('Hello, who are you?') ->usingProvider('lm_studio') ->generateText(); echo $result . "\n";
WordPress Plugin
After activating the plugin, the LM Studio provider is automatically registered with the AI Client. Use the AI Client API as usual:
use WordPress\AiClient\AiClient; $result = AiClient::prompt('Hello, who are you?') ->usingProvider('lm_studio') ->generateText();
License
GPL-2.0-or-later