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

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 — keys must match LLMConfig attribute names exactly
cognee.config.set_llm_config({
    "llm_provider": "openai",
    "llm_model": "gpt-4o",
    "llm_api_key": "sk-...",
})
set_llm_config() keys must match the internal attribute names on LLMConfig. The exact internal attributes name are displayed in the table below.
KeyTypeDefaultDescription
llm_providerstr"openai"Provider: "openai", "anthropic", "ollama", "gemini", "mistral", "bedrock", "azure", "custom"
llm_modelstr"openai/gpt-5-mini"Model identifier
llm_api_keystrNoneAPI key for the provider
llm_endpointstr""Custom endpoint URL (required for Ollama, vLLM, etc.)
llm_api_versionstrNoneAPI version (required for Azure)
llm_temperaturefloat0.0Response temperature (0.0–2.0)
llm_streamingboolFalseEnable streaming responses
llm_max_completion_tokensint16384Maximum tokens in the response
llm_argsdict{}Arbitrary provider-specific kwargs merged into every LLM call. Set as a JSON string in .env (e.g. LLM_ARGS='{"top_p": 0.9}').
llm_rate_limit_enabledboolFalseEnable client-side rate limiting for LLM calls
llm_rate_limit_requestsint60Max LLM requests allowed per interval
llm_rate_limit_intervalint60Duration of the rate limit window in seconds
llm_rate_limit_tokensint0Max tokens per interval (0 = disabled)
cognee.config.set_embedding_provider("fastembed")
cognee.config.set_embedding_model("BAAI/bge-small-en-v1.5")
cognee.config.set_embedding_dimensions(384)

# Or set all at once — keys must match EmbeddingConfig attribute names exactly
cognee.config.set_embedding_config({
    "embedding_provider": "fastembed",
    "embedding_model": "BAAI/bge-small-en-v1.5",
    "embedding_dimensions": 384,
})
KeyTypeDefaultDescription
embedding_providerstr"openai"Provider: "openai", "ollama", "fastembed", "gemini", "mistral", "bedrock", "custom"
embedding_modelstr"openai/text-embedding-3-large"Model identifier
embedding_dimensionsint3072Vector dimension size (must match your vector store)
embedding_api_keystrNoneAPI key (falls back to LLM_API_KEY if unset)
embedding_endpointstrNoneCustom endpoint URL
embedding_api_versionstrNoneAPI version
embedding_max_completion_tokensint8191Maximum tokens for embedding input
embedding_batch_sizeint36Batch size for embedding requests
huggingface_tokenizerstrNoneHuggingFace Hub model ID for token counting with Ollama
embedding_rate_limit_enabledboolFalseEnable client-side rate limiting for embedding calls
embedding_rate_limit_requestsint60Max embedding requests allowed per interval
embedding_rate_limit_intervalint60Duration of the rate limit window in seconds
embedding_rate_limit_tokensint0Max tokens per interval (0 = disabled)
cognee.config.set_graph_database_provider("kuzu")  # "kuzu", "neo4j", "kuzu-remote", "neptune", "neptune_analytics"

# Keys must match GraphConfig attribute names exactly
cognee.config.set_graph_db_config({
    "graph_database_provider": "neo4j",
    "graph_database_url": "bolt://localhost:7687",
    "graph_database_username": "neo4j",
    "graph_database_password": "password",
})
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")

# Keys must match VectorConfig attribute names exactly
cognee.config.set_vector_db_config({
    "vector_db_provider": "qdrant",
    "vector_db_url": "http://localhost:6333",
    "vector_db_key": "...",
})
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"
cognee.config.set_classification_model(MyClassifier)
cognee.config.set_summarization_model(MySummarizer)
cognee.config.set_graph_model(MyGraphModel)
cognee.config.system_root_directory("/custom/path")
cognee.config.data_root_directory("/data/path")
cognee.config.set_translation_provider("google")  # "llm", "google", "azure"
cognee.config.set_translation_target_language("en")

# Generic setter for supported keys
cognee.config.set("llm_model", "openai/gpt-5-mini")
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

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_embedding_provider(provider)Set the embedding provider
set_embedding_model(model)Set the embedding model name
set_embedding_dimensions(dimensions)Set embedding vector dimensions
set_embedding_endpoint(url)Set a custom embedding endpoint
set_embedding_api_key(key)Set the embedding API key
set_embedding_config(dict)Set all embedding config at once
set_graph_database_provider(provider)Set the graph DB provider
set_relational_db_config(dict)Set relational DB config
set_migration_db_config(dict)Set migration DB config
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
system_root_directory(path)Set system root directory
data_root_directory(path)Set data root directory
monitoring_tool(tool)Set the monitoring tool
set_translation_provider(provider)Set translation provider
set_translation_target_language(lang)Set translation target language
set_translation_config(dict)Set translation config
set(key, value)Generic config setter