Skip to content

Commit

Permalink
Add Optional Auth Token Support
Browse files Browse the repository at this point in the history
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');`
  • Loading branch information
ChobPT authored Nov 18, 2024
1 parent 734d9a4 commit 34e905c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/OllamaClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
]);
}

Expand Down

0 comments on commit 34e905c

Please sign in to comment.