Skip to content

php-client/ollama

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP client for Ollama API.

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.