[GH-ISSUE #639] Access Ollama with an API Key #407

Closed
opened 2026-03-02 11:49:35 +03:00 by kerem · 3 comments
Owner

Originally created by @genobi on GitHub (Nov 10, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/639

Describe the feature you'd like

I currently use Ollama via Open-WebUI in Docker. That provides a Ollama API but behind a per-user API key. That is more secure that having an open, unauthenticated API to our LLM server and I prefer that than trusting a closed network within Docker.

The request is to add a environmental variable within the Docker Compose to use an API key with the Ollama API.

Describe the benefits this would bring to existing Hoarder users

Allow secure access to Ollama instances that are secured with an API key

Can the goal of this request already be achieved via other means?

Not within Docker, that I know of.

Have you searched for an existing open/closed issue?

  • I have searched for existing issues and none cover my fundamental request

Additional context

No response

Originally created by @genobi on GitHub (Nov 10, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/639 ### Describe the feature you'd like I currently use Ollama via Open-WebUI in Docker. That provides a Ollama API but behind a per-user API key. That is more secure that having an open, unauthenticated API to our LLM server and I prefer that than trusting a closed network within Docker. The request is to add a environmental variable within the Docker Compose to use an API key with the Ollama API. ### Describe the benefits this would bring to existing Hoarder users Allow secure access to Ollama instances that are secured with an API key ### Can the goal of this request already be achieved via other means? Not within Docker, that I know of. ### Have you searched for an existing open/closed issue? - [X] I have searched for existing issues and none cover my fundamental request ### Additional context _No response_
kerem 2026-03-02 11:49:35 +03:00
Author
Owner

@kamtschatka commented on GitHub (Nov 11, 2024):

any documentation you can provide so we can see what you have set up?
This? https://docs.openwebui.com/getting-started/advanced-topics/api-endpoints
So we would need to provide a "bearer <api-token>" Authorization header?

<!-- gh-comment-id:2468655793 --> @kamtschatka commented on GitHub (Nov 11, 2024): any documentation you can provide so we can see what you have set up? This? https://docs.openwebui.com/getting-started/advanced-topics/api-endpoints So we would need to provide a "bearer \<api-token>\" Authorization header?
Author
Owner

@genobi commented on GitHub (Nov 11, 2024):

Yes! I have been looking over those very docs (and using their search) and totally missed that.
I tried the OpenAI compatible version using the docker env to set the base URL and ran into issues (generic 400 bad request errors). Since I could not easily see the traffic, I couldn't figure out what was going on. So I tried the Ollama end point and got a 401 error. When I tried with my API client, using the bearer header, it worked as intended. So I was hoping to just get that working

On that note, the ollama library I think Hoarder uses doesn't document any way to include an API key. That being said according to the source:37, it should be able to take a "headers" property on the initialization call along with the host property.

I was going to try to try and implement this and pitch a fix, but I have no yet had time.

<!-- gh-comment-id:2468738674 --> @genobi commented on GitHub (Nov 11, 2024): Yes! I have been looking over those very docs (and using their search) and totally missed that. I tried the OpenAI compatible version using the docker env to set the base URL and ran into issues (generic 400 bad request errors). Since I could not easily see the traffic, I couldn't figure out what was going on. So I tried the Ollama end point and got a 401 error. When I tried with my API client, using the bearer <api-token> header, it worked as intended. So I was hoping to just get that working On that note, the ollama library I think Hoarder uses doesn't document any way to include an API key. That being said according to the [source](https://github.com/ollama/ollama-js/blob/main/src/browser.ts):37, it should be able to take a "headers" property on the initialization call along with the host property. I was going to try to try and implement this and pitch a fix, but I have no yet had time.
Author
Owner

@MohamedBassem commented on GitHub (May 17, 2025):

Ollama supports OpenAI API: https://ollama.com/blog/openai-compatibility

My recommendation now is going to be asking users to use ollama over the openai API instead which will allow you to pass an API key if needed. Eventually, I'll deprecate the old ollama env variables.

<!-- gh-comment-id:2888408892 --> @MohamedBassem commented on GitHub (May 17, 2025): Ollama supports OpenAI API: https://ollama.com/blog/openai-compatibility My recommendation now is going to be asking users to use ollama over the openai API instead which will allow you to pass an API key if needed. Eventually, I'll deprecate the old ollama env variables.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#407
No description provided.