Skip to main content

cognee.config

Static class for configuring Cognee’s runtime settings. All setters persist for the duration of the process (or until overridden). Use cognee.config.set(...) for supported runtime-safe settings inside a Python process. Cognee can also be configured through .env or process environment variables before import. Use those for process-level settings such as auth, logging, cache backend, storage backend, telemetry, API server settings, and deployment credentials. For the full environment variable reference and precedence rules, see Setup Configuration.

Configuration Types

set_llm_config() keys must match the internal attribute names on LLMConfig. The exact internal attributes name are displayed in the table below.

Reading configuration

get(key) returns the current value of any key set() accepts, and get_all() returns all of them as a dict. Both mask secret values (llm_api_key, embedding_api_key, vector_db_key) by default, keeping only the first three and last four characters as a hint (values of eight characters or fewer are masked entirely); pass reveal_secrets=True to get the raw value. get() raises InvalidConfigAttributeError for an unrecognized key.

Persisting a value to .env

set() normally only updates the in-process configuration. Pass persist=True to also write the resolved value into the .env file this process loaded, so it is picked up by the next process that resolves the same file. That target may be a file pinned with COGNEE_ENV_FILE or a .env found in a parent directory — see How .env Is Loaded. Only when no .env was resolved does it fall back to .env in the current working directory, creating it if missing. This is what cognee-cli config set does. When persisting, set() returns a dict describing where the value was written:
Without persist=True, set() returns None and changes nothing on disk.
Persisting a secret writes it in plaintext to the .env this process loaded, which may sit in a parent directory rather than the one you are running from. Check the returned path (or the resolved-.env line in the startup log) to see where it landed, keep that file out of version control, and restrict its permissions.
cognee.config.set(key, value) is not a free-form setter. Use it for supported runtime-safe settings such as LLMs, embeddings, graph/vector databases, chunking, model overrides, and root directories. Use .env, shell variables, deployment variables, or pre-import os.environ for process-level settings such as auth, logging, cache backend, storage backend, API server settings, telemetry, and cloud credentials.

All Configuration Methods