Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/ollama/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/ollama is installed like any Composer package. Before you begin, make sure your local environment satisfies the prerequisites below — specifically that an Ollama server is reachable, because every API call the SDK makes is a live HTTP request to that server.
System Requirements
| Requirement | Details |
|---|---|
| PHP | ^8.3 |
| Composer | Any current version |
| Ollama | A running Ollama server. See ollama.com for installation instructions. |
| PSR-18 HTTP client | Any PSR-18-compliant client: Guzzle, Symfony HTTP Client, or another. The SDK uses PSR-18 discovery to find your client automatically. |
Installation
Install the package via Composer
Run the following command in your project root:This installs
aisdk/ollama and its two dependencies — aisdk/core and aisdk/openai-compatible — into your vendor/ directory.Pull a model from the Ollama library
Use the Ollama CLI to download a model onto your server. For example, to pull Llama 3.2:Pass the same model name string to
Ollama::model() when constructing requests. Any model available in the Ollama library can be pulled this way.Verify Ollama is running
Start the Ollama server if it is not already running:To confirm the server is reachable and inspect your installed models, call the native tags endpoint:A successful response returns a JSON object listing every model available on the server. The SDK’s
Ollama::availableModels() method calls this same endpoint.Autoloading
The package registers two PSR-4 namespace mappings in itscomposer.json:
| Namespace | Source directory | What lives here |
|---|---|---|
AiSdk\ | src/Root/ | The Ollama static facade — the primary entry point |
AiSdk\Ollama\ | src/ | OllamaProvider, OllamaOptions, model adapters, and supporting classes |
composer require. You do not need to add any require or include statements in your code.
Environment Variables
The provider reads optional configuration from your environment. Set these in your.env file or shell before any SDK calls are made:
| Variable | Description | Default |
|---|---|---|
OLLAMA_BASE_URL | Base URL for the OpenAI-compatible API | http://localhost:11434/v1 |
OLLAMA_NATIVE_BASE_URL | Base URL for native API endpoints (tags, show, embed) | Derived by stripping /v1 from OLLAMA_BASE_URL |
OLLAMA_API_KEY | Optional bearer token for protected servers | — |
Ollama::create():
