This is a PHP client for the Ollama API.
Install the package via composer:
composer require php-client/ollama
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.
- 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
This package is released under the MIT License.