AI: Add support for OLLAMA_API_KEY and OLLAMA_BASE_URL to configure Ollama #2447

Open
opened 2026-02-20 01:11:38 -05:00 by deekerman · 3 comments
Owner

Originally created by @lastzero on GitHub (Dec 3, 2025).

Originally assigned to: @graciousgrey, @omerdduran on GitHub.

As an Ollama Cloud user, I want to be able to set my API key via OLLAMA_API_KEY and the service base URL via OLLAMA_BASE_URL, rather than having to set them manually in my vision.yml file.

👉 https://docs.ollama.com/cloud#cli

Originally created by @lastzero on GitHub (Dec 3, 2025). Originally assigned to: @graciousgrey, @omerdduran on GitHub. **As an Ollama Cloud user, I want to be able to set my API key via `OLLAMA_API_KEY` and the service base URL via `OLLAMA_BASE_URL`, rather than having to set them manually in my `vision.yml` file.** 👉 https://docs.ollama.com/cloud#cli
Author
Owner

@lastzero commented on GitHub (Dec 4, 2025):

@graciousgrey @omerdduran These changes should ensure that the built-in caption model default/example only runs manually and isn't flagged as a default model. This is to prevent the standard vision config from always sending requests to http://ollama:11434/api/generate during or after indexing, since most users either won't have an Ollama instance, or if they have one, it might use a different URL. Please make sure to double-check that this works! Alternatively, we can remove the built-in caption model default/example.

@lastzero commented on GitHub (Dec 4, 2025): @graciousgrey @omerdduran These changes should ensure that the built-in `caption` model default/example only runs manually and isn't flagged as a default model. This is to prevent the standard vision config from always sending requests to `http://ollama:11434/api/generate` during or after indexing, since most users either won't have an Ollama instance, or if they have one, it might use a different URL. Please make sure to double-check that this works! Alternatively, we can remove the built-in caption model default/example.
Author
Owner

@lastzero commented on GitHub (Dec 10, 2025):

My last commit includes the following changes and improvements:

  • Added OLLAMA_BASE_URL var expansion: Ollama engine now resolves ${OLLAMA_BASE_URL:-http://ollama:11434}/api/generate, trims trailing slashes, and only switches to cloud defaults when OLLAMA_BASE_URL=https://ollama.com. An API key alone no longer forces cloud usage.
  • Centralized env normalization in initEnvUrl()/ensureEnv(), so placeholders expand reliably and unset values get the local default instead of leaking ${…} into requests.
  • Updated docker images to seed OLLAMA_BASE_URL="http://ollama:11434" for convenience; vision tests and fixtures now use the placeholder form.
  • Updated documentation to align with the new behavior; examples now use ${OLLAMA_BASE_URL}/api/generate.
  • Added unit tests covering base-URL normalization, cloud detection via base URL, and placeholder expansion/fallback.
@lastzero commented on GitHub (Dec 10, 2025): My last commit includes the following **changes and improvements**: - Added `OLLAMA_BASE_URL` var expansion: Ollama engine now resolves `${OLLAMA_BASE_URL:-http://ollama:11434}/api/generate`, trims trailing slashes, and only switches to cloud defaults when `OLLAMA_BASE_URL=https://ollama.com`. An API key alone no longer forces cloud usage. - Centralized env normalization in `initEnvUrl()`/`ensureEnv()`, so placeholders expand reliably and unset values get the local default instead of leaking `${…}` into requests. - ~~Updated docker images to seed `OLLAMA_BASE_URL="http://ollama:11434"` for convenience; vision tests and fixtures now use the placeholder form.~~ - Updated documentation to align with the new behavior; examples now use `${OLLAMA_BASE_URL}/api/generate`. - Added unit tests covering base-URL normalization, cloud detection via base URL, and placeholder expansion/fallback.
Author
Owner

@lastzero commented on GitHub (Dec 11, 2025):

You can use our preview build to test this:

services:
  photoprism:
    image: photoprism/photoprism:preview
    environment:
      OLLAMA_BASE_URL: "http://ollama:11434"         # use "https://ollama.com" for Ollama Cloud
      OLLAMA_API_KEY: ""                             # API key required to access Ollama (optional)
@lastzero commented on GitHub (Dec 11, 2025): You can use our [preview build](https://docs.photoprism.app/release-notes/#development-preview) to test this: ```yaml services: photoprism: image: photoprism/photoprism:preview environment: OLLAMA_BASE_URL: "http://ollama:11434" # use "https://ollama.com" for Ollama Cloud OLLAMA_API_KEY: "" # API key required to access Ollama (optional) ```
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/photoprism#2447
No description provided.