papi-ai / ollama
Ollama (local) provider for PapiAI
v0.16.2
2026-11-16 20:40 UTC
Requires
- php: ^8.2
- ext-curl: *
- papi-ai/papi-core: ^0.15.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- pestphp/pest: ^3.0
- vimeo/psalm: ^6.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Ollama provider for PapiAI - A simple but powerful PHP library for building AI agents.
Installation
composer require papi-ai/ollama
Usage
use PapiAI\Core\Agent; use PapiAI\Ollama\OllamaProvider; $provider = new OllamaProvider(); $agent = new Agent( provider: $provider, instructions: 'You are a helpful assistant.', ); $response = $agent->run('Hello!'); echo $response->text;
Available Models
The following models are supported (as referenced in OllamaProvider):
| Model | Type |
|---|---|
llama3.1 |
General purpose |
codellama |
Code generation |
mistral |
General purpose |
mixtral |
Mixture of experts |
qwen2.5-coder |
Code generation |
nomic-embed-text |
Embeddings (default) |
Features
- Tool/function calling
- Streaming support
- Embeddings support
- Vision support
- Structured output / JSON mode
- Runs locally via Ollama (no API key required)
Creating It by Name
An application that picks its provider from configuration can build this one without naming its class:
use PapiAI\Core\Factory\ComposerDiscovery; use PapiAI\Core\Factory\ProviderRegistry; $registry = new ProviderRegistry(new ComposerDiscovery()); $provider = $registry->create('ollama', [ 'model' => 'llama3.1', ]);
It takes base_url, model, max_tokens and effort. Anything it is not given falls back to the
constructor's defaults, and a missing or unknown setting throws ConfigurationException before any
request is made.
License
MIT