Set up Ollama
Researched from Ollama's official documentation on 2026-11-02. Not yet walked through end to end.
- Current: Install Ollama locally
Use the official installer for your operating system, then open Ollama. On Linux, start its local server if it is not running.
- Not started: Download a local model
Choose a model that fits your hardware and run ollama pull with that model name on your own machine. Use a local model, not a cloud-suffixed model, for this walkthrough.
- Not started: Keep the API on your machine
Use the installed localhost endpoint below from the same machine as your application. Keep it bound to loopback; this guide does not expose your Ollama server to the internet.
- Not started: Configure your .env
Use the environment names below in your own application. Keep its environment file out of source control. Never paste a key into this website.
- Not started: Run the local check
Choose a model you can use and run the matching example below on your own machine. Check any applicable usage charges first.
This provider is available in PHP Prism. The TypeScript and Python ports do not implement it.
Configure and verify locally
Environment names and defaults below come from the installed package. Choose a model you can use by setting PRISM_SETUP_MODEL on your machine. Run the verification only when you are ready for one local request. No request is sent by this page.
use Prism\Prism\Facades\Prism;
// Run in your own configured Laravel app (for example, php artisan tinker).
$model = getenv('PRISM_SETUP_MODEL');
if (!$model) {
throw new RuntimeException('Set PRISM_SETUP_MODEL to your model.');
}
try {
$result = Prism::text()
->using('ollama', $model)
->withPrompt('Say hello.')
->withMaxTokens(32)
->asText();
echo $result->text, PHP_EOL;
} catch (Throwable $error) {
echo get_class($error), PHP_EOL;
}