calesthio/OpenMontage · error · RuntimeError

PEXELS_API_KEY not set. Get a free key at https://www.pexels

Error message

PEXELS_API_KEY not set. Get a free key at https://www.pexels.com/api/ and add it to .env.

What it means

Error "PEXELS_API_KEY not set. Get a free key at https://www.pexels.com/api/ and add it to .env." thrown in calesthio/OpenMontage.

Source

Thrown at tools/video/stock_sources/pexels.py:106

        with requests.get(
            candidate.download_url, stream=True, timeout=120
        ) as r:
            r.raise_for_status()
            with open(out_path, "wb") as f:
                for chunk in r.iter_content(chunk_size=1 << 16):
                    if chunk:
                        f.write(chunk)
        return out_path

    # ------------------------------------------------------------------
    # Internals
    # ------------------------------------------------------------------

    def _headers(self) -> dict[str, str]:
        key = os.environ.get("PEXELS_API_KEY")
        if not key:
            raise RuntimeError(
                "PEXELS_API_KEY not set. Get a free key at "
                "https://www.pexels.com/api/ and add it to .env."
            )
        return {"Authorization": key}

    def _search_videos(
        self, query: str, filters: SearchFilters
    ) -> list[Candidate]:
        import requests  # lazy

        params: dict[str, Any] = {
            "query": query,
            "per_page": max(1, min(filters.per_page, 80)),
            "page": max(1, filters.page),
        }
        if filters.orientation:
            params["orientation"] = filters.orientation

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Get a free API key at https://www.pexels.com/api/ and set PEXELS_API_KEY in the environment or .env file.
  2. Restart the process after adding the key so the environment is reloaded.

When it happens

Trigger: The Pexels stock source is used without PEXELS_API_KEY set in the environment.

Common situations: See trigger scenarios.


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/b132f043284557d6. Report an issue: GitHub.