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 a .env file in the current working directory (created if missing), so it is picked up by the next process started from that directory. 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 .env in whatever directory the process is running from. 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