php-client / ollama
PHP Client for Ollama API
v0.1.0
2025-02-13 16:04 UTC
Requires
- php: ^8.3
- saloonphp/saloon: ^3.10
Requires (Dev)
- symfony/var-dumper: ^7.2
- vlucas/phpdotenv: ^5.6
This package is auto-updated.
Last update: 2025-05-30 16:04:55 UTC
README
This is a PHP client for the Ollama API.
Installation
Install the package via composer:
composer require php-client/ollama
Usage
Simple example:
use PhpClient\Ollama\Ollama; $ollama = new Ollama('http://localhost:11434'); $response = $ollama->generation()->generateCompletion([ 'model' => 'llama3.2:latest', 'prompt' => 'Hello!', // Wait for end of generation before getting response: 'stream' => false, ]); echo $response->json('response');
More information available in comments and PhpDocs in the code.
Also please check the official Ollama API docs.
List of available API actions
- Generation
- Generate completions
- Generate chat completions
- Generate embeddings
- Management
- List local models
- List running models
- Show model information
- Load|Unload model
- Pull|Push model
- Create|Copy|Delete model
- Check blob exists
- Version
License
This package is released under the MIT License.