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).

LLM Configuration

cognee.config.set_llm_provider("openai")          # "openai", "anthropic", "ollama", "gemini", "mistral", "bedrock"
cognee.config.set_llm_model("gpt-4o-mini")
cognee.config.set_llm_api_key("sk-...")
cognee.config.set_llm_endpoint("https://custom-endpoint.example.com")

# Or set all at once
cognee.config.set_llm_config({
    "provider": "openai",
    "model": "gpt-4o",
    "api_key": "sk-...",
})

Graph Database Configuration

cognee.config.set_graph_database_provider("kuzu")  # "kuzu", "neo4j", "falkordb", "networkx"

cognee.config.set_graph_db_config({
    "provider": "neo4j",
    "url": "bolt://localhost:7687",
    "username": "neo4j",
    "password": "password",
})

Vector Database Configuration

cognee.config.set_vector_db_provider("lancedb")    # "lancedb", "pgvector", "qdrant", "chromadb"
cognee.config.set_vector_db_url("http://localhost:6333")
cognee.config.set_vector_db_key("your-key")

cognee.config.set_vector_db_config({
    "provider": "qdrant",
    "url": "http://localhost:6333",
    "api_key": "...",
})

Chunking Configuration

cognee.config.set_chunk_size(1024)
cognee.config.set_chunk_overlap(128)
cognee.config.set_chunk_strategy("PARAGRAPH")      # "EXACT", "PARAGRAPH", "SENTENCE", "CODE"
cognee.config.set_chunk_engine("DEFAULT_ENGINE")    # "DEFAULT_ENGINE", "LANGCHAIN_ENGINE"

Model Configuration

cognee.config.set_classification_model(MyClassifier)
cognee.config.set_summarization_model(MySummarizer)
cognee.config.set_graph_model(MyGraphModel)

Other Settings

cognee.config.set_system_root_directory("/custom/path")
cognee.config.set_data_root_directory("/data/path")
cognee.config.set_translation_provider("deepl")
cognee.config.set_translation_target_language("en")

# Generic setter for any config key
cognee.config.set("custom_key", value)

All Methods

MethodDescription
set_llm_provider(provider)Set the LLM provider
set_llm_model(model)Set the LLM model name
set_llm_api_key(key)Set the LLM API key
set_llm_endpoint(url)Set a custom LLM endpoint
set_llm_config(dict)Set all LLM config at once
set_graph_database_provider(provider)Set the graph DB provider
set_graph_db_config(dict)Set all graph DB config
set_vector_db_provider(provider)Set the vector DB provider
set_vector_db_url(url)Set the vector DB URL
set_vector_db_key(key)Set the vector DB API key
set_vector_db_config(dict)Set all vector DB config
set_chunk_size(size)Set chunk size in tokens
set_chunk_overlap(overlap)Set chunk overlap
set_chunk_strategy(strategy)Set chunking strategy
set_chunk_engine(engine)Set chunking engine
set_classification_model(model)Set classification model
set_summarization_model(model)Set summarization model
set_graph_model(model)Set graph extraction model
set_system_root_directory(path)Set system root directory
set_data_root_directory(path)Set data root directory
set_translation_provider(provider)Set translation provider
set_translation_target_language(lang)Set translation target language
set(key, value)Generic config setter

Environment Variables

These environment variables are read at startup and can be overridden with the config methods above:
VariableDefaultDescription
LLM_API_KEY(Required) API key for the LLM provider
LLM_PROVIDER"openai"LLM provider name
LLM_MODEL"gpt-4o-mini"LLM model identifier
LLM_ENDPOINTCustom LLM endpoint URL
GRAPH_DATABASE_PROVIDER"kuzu"Graph database provider
VECTOR_DB_PROVIDER"lancedb"Vector database provider
LOG_LEVEL"INFO"Logging level