> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# config

> Configure LLM providers, databases, chunking, and more

# cognee.config

Static class for configuring Cognee's runtime settings. All setters persist
for the duration of the process (or until overridden).

## Configuration Types

<AccordionGroup>
  <Accordion title="LLM Configuration">
    ```python theme={null}
    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.

    <Accordion title="Internal LLM Configuration attributes">
      | Key                         | Type    | Default               | Description                                                                                                                       |
      | --------------------------- | ------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
      | `llm_provider`              | `str`   | `"openai"`            | Provider: `"openai"`, `"anthropic"`, `"ollama"`, `"gemini"`, `"mistral"`, `"bedrock"`, `"azure"`, `"custom"`                      |
      | `llm_model`                 | `str`   | `"openai/gpt-5-mini"` | Model identifier                                                                                                                  |
      | `llm_api_key`               | `str`   | `None`                | API key for the provider                                                                                                          |
      | `llm_endpoint`              | `str`   | `""`                  | Custom endpoint URL (required for Ollama, vLLM, etc.)                                                                             |
      | `llm_api_version`           | `str`   | `None`                | API version (required for Azure)                                                                                                  |
      | `llm_temperature`           | `float` | `0.0`                 | Response temperature (0.0–2.0)                                                                                                    |
      | `llm_streaming`             | `bool`  | `False`               | Enable streaming responses                                                                                                        |
      | `llm_max_completion_tokens` | `int`   | `16384`               | Maximum tokens in the response                                                                                                    |
      | `llm_args`                  | `dict`  | `{}`                  | 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_enabled`    | `bool`  | `False`               | Enable client-side rate limiting for LLM calls                                                                                    |
      | `llm_rate_limit_requests`   | `int`   | `60`                  | Max LLM requests allowed per interval                                                                                             |
      | `llm_rate_limit_interval`   | `int`   | `60`                  | Duration of the rate limit window in seconds                                                                                      |
      | `llm_rate_limit_tokens`     | `int`   | `0`                   | Max tokens per interval (`0` = disabled)                                                                                          |
    </Accordion>
  </Accordion>

  <Accordion title="Embedding Configuration">
    ```python theme={null}
    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,
    })
    ```

    <Accordion title="Internal Embedding Configuration attributes">
      | Key                               | Type   | Default                           | Description                                                                                       |
      | --------------------------------- | ------ | --------------------------------- | ------------------------------------------------------------------------------------------------- |
      | `embedding_provider`              | `str`  | `"openai"`                        | Provider: `"openai"`, `"ollama"`, `"fastembed"`, `"gemini"`, `"mistral"`, `"bedrock"`, `"custom"` |
      | `embedding_model`                 | `str`  | `"openai/text-embedding-3-large"` | Model identifier                                                                                  |
      | `embedding_dimensions`            | `int`  | `3072`                            | Vector dimension size (must match your vector store)                                              |
      | `embedding_api_key`               | `str`  | `None`                            | API key (falls back to `LLM_API_KEY` if unset)                                                    |
      | `embedding_endpoint`              | `str`  | `None`                            | Custom endpoint URL                                                                               |
      | `embedding_api_version`           | `str`  | `None`                            | API version                                                                                       |
      | `embedding_max_completion_tokens` | `int`  | `8191`                            | Maximum tokens for embedding input                                                                |
      | `embedding_batch_size`            | `int`  | `36`                              | Batch size for embedding requests                                                                 |
      | `huggingface_tokenizer`           | `str`  | `None`                            | HuggingFace Hub model ID for token counting with Ollama                                           |
      | `embedding_rate_limit_enabled`    | `bool` | `False`                           | Enable client-side rate limiting for embedding calls                                              |
      | `embedding_rate_limit_requests`   | `int`  | `60`                              | Max embedding requests allowed per interval                                                       |
      | `embedding_rate_limit_interval`   | `int`  | `60`                              | Duration of the rate limit window in seconds                                                      |
      | `embedding_rate_limit_tokens`     | `int`  | `0`                               | Max tokens per interval (`0` = disabled)                                                          |
    </Accordion>
  </Accordion>

  <Accordion title="Graph Database Configuration">
    ```python theme={null}
    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",
    })
    ```
  </Accordion>

  <Accordion title="Vector Database Configuration">
    ```python theme={null}
    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": "...",
    })
    ```
  </Accordion>

  <Accordion title="Chunking Configuration">
    ```python theme={null}
    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"
    ```
  </Accordion>

  <Accordion title="Model Configuration">
    ```python theme={null}
    cognee.config.set_classification_model(MyClassifier)
    cognee.config.set_summarization_model(MySummarizer)
    cognee.config.set_graph_model(MyGraphModel)
    ```
  </Accordion>

  <Accordion title="Other Settings">
    ```python theme={null}
    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")
    ```

    <Warning>
      `cognee.config.set(key, value)` is not a free-form setter. It supports a fixed set of keys plus valid embedding config attributes. Unsupported keys raise `InvalidConfigAttributeError`.
    </Warning>
  </Accordion>
</AccordionGroup>

## All Configuration Methods

<Accordion title="Configuration Methods">
  | Method                                  | Description                      |
  | --------------------------------------- | -------------------------------- |
  | `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            |
</Accordion>

## Environment Variables

These environment variables are read at startup and can be overridden with
the config methods above:

| Variable                        | Default               | Description                                                                      |
| ------------------------------- | --------------------- | -------------------------------------------------------------------------------- |
| `LLM_API_KEY`                   | —                     | **(Required)** API key for the LLM provider                                      |
| `LLM_PROVIDER`                  | `"openai"`            | LLM provider name                                                                |
| `LLM_MODEL`                     | `"openai/gpt-5-mini"` | LLM model identifier                                                             |
| `LLM_ENDPOINT`                  | —                     | Custom LLM endpoint URL                                                          |
| `LLM_ARGS`                      | `"{}"`                | JSON string of extra kwargs merged into every LLM call (e.g. `'{"top_p": 0.9}'`) |
| `LLM_RATE_LIMIT_ENABLED`        | `false`               | Enable client-side rate limiting for LLM calls                                   |
| `LLM_RATE_LIMIT_REQUESTS`       | `60`                  | Max LLM requests per interval                                                    |
| `LLM_RATE_LIMIT_INTERVAL`       | `60`                  | Rate limit window in seconds                                                     |
| `LLM_RATE_LIMIT_TOKENS`         | `0`                   | Max LLM tokens per interval (`0` = disabled)                                     |
| `EMBEDDING_RATE_LIMIT_ENABLED`  | `false`               | Enable client-side rate limiting for embedding calls                             |
| `EMBEDDING_RATE_LIMIT_REQUESTS` | `60`                  | Max embedding requests per interval                                              |
| `EMBEDDING_RATE_LIMIT_INTERVAL` | `60`                  | Rate limit window in seconds                                                     |
| `EMBEDDING_RATE_LIMIT_TOKENS`   | `0`                   | Max embedding tokens per interval (`0` = disabled)                               |
| `GRAPH_DATABASE_PROVIDER`       | `"kuzu"`              | Graph database provider                                                          |
| `VECTOR_DB_PROVIDER`            | `"lancedb"`           | Vector database provider                                                         |
| `LOG_LEVEL`                     | `"INFO"`              | Logging level                                                                    |
