From 34e905c6927ab66aad7292134f2bc8e2193c38d0 Mon Sep 17 00:00:00 2001 From: ChobPT <45816945+ChobPT@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:01:25 +0000 Subject: [PATCH] Add Optional Auth Token Support For instances that require an auth token, this adds the possibility to init the client with `$client = \ArdaGnsrn\Ollama\Ollama::client('http://localhost:11434','API_KEY');` --- src/OllamaClient.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/OllamaClient.php b/src/OllamaClient.php index 6bfbe11..8806038 100644 --- a/src/OllamaClient.php +++ b/src/OllamaClient.php @@ -16,10 +16,13 @@ class OllamaClient /** * @param string $host */ - public function __construct(string $host = 'http://localhost:11434') + public function __construct(string $host = 'http://localhost:11434', string $apiKey = '') { $this->guzzleClient = new Client([ 'base_uri' => "$host/api/", + 'headers' => [ + 'Authorization' => "Bearer $apiKey", + ], ]); }