stanford-oval/storm · error · ValueError

Please provide an api key.

Error message

Please provide an api key.

What it means

For source='online', VectorRM.init_online_vector_db requires an api_key either as an argument or via the QDRANT_API_KEY environment variable. If neither is present it raises ValueError before constructing the QdrantClient, since managed/Qdrant Cloud endpoints authenticate with API keys.

Source

Thrown at knowledge_storm/rm.py:262

            )
        else:
            raise ValueError(
                f"Collection {self.collection_name} does not exist. Please create the collection first."
            )

    def init_online_vector_db(self, url: str, api_key: str):
        from qdrant_client import QdrantClient

        """
        Initialize the Qdrant client that is connected to an online vector store with the given URL and API key.

        Args:
            url (str): URL of the Qdrant server.
            api_key (str): API key for the Qdrant server.
        """
        if api_key is None:
            if not os.getenv("QDRANT_API_KEY"):
                raise ValueError("Please provide an api key.")
            api_key = os.getenv("QDRANT_API_KEY")
        if url is None:
            raise ValueError("Please provide a url for the Qdrant server.")

        try:
            self.client = QdrantClient(url=url, api_key=api_key)
            self._check_collection()
        except Exception as e:
            raise ValueError(f"Error occurs when connecting to the server: {e}")

    def init_offline_vector_db(self, vector_store_path: str):
        from qdrant_client import QdrantClient

        """
        Initialize the Qdrant client that is connected to an offline vector store with the given vector store folder path.

        Args:
            vector_store_path (str): Path to the vector store.

View on GitHub (pinned to fb951af774)

Solutions

  1. Pass api_key directly: rm.init_online_vector_db(url=..., api_key='your-key')
  2. Or export the environment variable: export QDRANT_API_KEY=your-key (and load it in code via load_dotenv() if using .env)
  3. Copy the key from Qdrant Cloud dashboard -> API Keys for your cluster

Example fix

// before
rm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333')
// after
rm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=os.environ['QDRANT_API_KEY'])
Defensive patterns

Strategy: validation

Validate before calling

import os
api_key = os.getenv('QDRANT_API_KEY')
if not api_key:
    raise SystemExit('Set QDRANT_API_KEY or pass api_key= to init_online_vector_db')
rm.init_online_vector_db(url='https://xyz.cloud.qdrant.io:6333', api_key=api_key)

Type guard

def has_qdrant_credentials(api_key: str | None) -> bool:
    import os
    return bool(api_key or os.getenv('QDRANT_API_KEY'))

Try / catch

try:
    rm.init_online_vector_db(url=URL, api_key=None)
except ValueError as e:
    if 'api key' in str(e):
        raise SystemExit('Missing QDRANT_API_KEY — add it to your environment')
    raise

Prevention

When it happens

Trigger: Calling rm.init_online_vector_db(url='https://xyz.eu-central.aws.cloud.qdrant.io:6333') without api_key while QDRANT_API_KEY is unset; calling with api_key=None explicitly; CI shells where .env was never loaded.

Common situations: Forgetting to export QDRANT_API_KEY in the shell/CI; assuming the key is read from a .env file automatically without python-dotenv; copying examples that only pass url.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of stanford-oval/storm@fb951af774 (2026-08-28). Data as JSON: /api/errors/38c7ba1b89c888e5. Report an issue: GitHub.