Skip to content

Latest commit

 

History

History
179 lines (137 loc) · 13.2 KB

configuration.md

File metadata and controls

179 lines (137 loc) · 13.2 KB
description Configure Code-Graph-RAG with provider settings, environment variables, and model options.

Configuration

Configuration is managed through environment variables in the .env file. The provider-explicit configuration supports mixing different providers for orchestrator and cypher models.

Set a role's *_PROVIDER and *_MODEL together. If neither is set, that role uses the local Ollama default (llama3.2). Setting only one of them (for example ORCHESTRATOR_PROVIDER=anthropic without ORCHESTRATOR_MODEL) is an error: cgr start exits with a message naming the missing variable, and cgr doctor reports it as a failed check.

A .env with ORCHESTRATOR_PROVIDER but no ORCHESTRATOR_MODEL: cgr doctor fails the check and cgr start exits naming the missing variable

A value cgr cannot use (a port that is not a number, MEMGRAPH_BATCH_SIZE=0) stops every command before it runs, with one line per variable naming the value and whether it came from ./.env or the environment, and exit status 2. cgr --version, cgr --help and cgr help <command> still work, so you can find the fix. A variable set to an empty value (MEMGRAPH_HOST=) counts as unset and takes its default. A ./.env value the operating system will not hold in a variable (one with a NUL byte, or longer than the 32,767 characters Windows allows) is reported the same way, naming the variable but not the value, and the rest of the file still loads.

Provider Examples

All Ollama (Local Models)

ORCHESTRATOR_PROVIDER=ollama
ORCHESTRATOR_MODEL=qwen2.5-coder
ORCHESTRATOR_ENDPOINT=http://localhost:11434/v1

CYPHER_PROVIDER=ollama
CYPHER_MODEL=qwen2.5-coder
CYPHER_ENDPOINT=http://localhost:11434/v1

All OpenAI Models

ORCHESTRATOR_PROVIDER=openai
ORCHESTRATOR_MODEL=gpt-5.6-terra
ORCHESTRATOR_API_KEY=sk-your-openai-key

CYPHER_PROVIDER=openai
CYPHER_MODEL=gpt-5.6-luna
CYPHER_API_KEY=sk-your-openai-key

All Google Models

ORCHESTRATOR_PROVIDER=google
ORCHESTRATOR_MODEL=gemini-3.6-flash
ORCHESTRATOR_API_KEY=your-google-api-key

CYPHER_PROVIDER=google
CYPHER_MODEL=gemini-3.5-flash-lite
CYPHER_API_KEY=your-google-api-key

Get your Google API key from Google AI Studio.

Mixed Providers

ORCHESTRATOR_PROVIDER=google
ORCHESTRATOR_MODEL=gemini-3.6-flash
ORCHESTRATOR_API_KEY=your-google-api-key

CYPHER_PROVIDER=ollama
CYPHER_MODEL=qwen2.5-coder
CYPHER_ENDPOINT=http://localhost:11434/v1

cgr doctor reading the mixed-provider .env: Google credentials present, local Ollama not reachable

The key is the placeholder above: cgr doctor only checks that one is present. No Ollama runs on the recording machine.

MiniMax Models

ORCHESTRATOR_PROVIDER=minimax
ORCHESTRATOR_MODEL=MiniMax-M3
ORCHESTRATOR_API_KEY=your-minimax-api-key
ORCHESTRATOR_ENDPOINT=https://api.minimax.io/v1

CYPHER_PROVIDER=minimax
CYPHER_MODEL=MiniMax-M2.7
CYPHER_API_KEY=your-minimax-api-key
CYPHER_ENDPOINT=https://api.minimax.io/anthropic

Both model IDs work with either compatible endpoint. For the China service, use https://api.minimaxi.com/v1 or https://api.minimaxi.com/anthropic.

Get your MiniMax API key from the MiniMax Platform.

Orchestrator Model Settings

Variable Description
ORCHESTRATOR_PROVIDER Provider name (google, openai, anthropic, azure, ollama, minimax, litellm_proxy)
ORCHESTRATOR_MODEL Model ID (e.g., gemini-3.6-flash, gpt-5.6-terra, claude-sonnet-5, qwen2.5-coder; gemini-3.1-pro-preview for a heavier option)
ORCHESTRATOR_API_KEY API key for the provider (if required)
ORCHESTRATOR_ENDPOINT Custom endpoint URL (if required)
ORCHESTRATOR_PROJECT_ID Google Cloud project ID (for Vertex AI)
ORCHESTRATOR_REGION Google Cloud region (default: us-central1)
ORCHESTRATOR_PROVIDER_TYPE Google provider type (gla or vertex)
ORCHESTRATOR_THINKING_BUDGET Thinking budget for reasoning models
ORCHESTRATOR_SERVICE_ACCOUNT_FILE Path to service account file (for Vertex AI)

Cypher Model Settings

Variable Description
CYPHER_PROVIDER Provider name (google, openai, anthropic, azure, ollama, minimax, litellm_proxy)
CYPHER_MODEL Model ID (e.g., gemini-3.5-flash-lite, gpt-5.6-luna, qwen2.5-coder)
CYPHER_API_KEY API key for the provider (if required)
CYPHER_ENDPOINT Custom endpoint URL (if required)
CYPHER_PROJECT_ID Google Cloud project ID (for Vertex AI)
CYPHER_REGION Google Cloud region (default: us-central1)
CYPHER_PROVIDER_TYPE Google provider type (gla or vertex)
CYPHER_THINKING_BUDGET Thinking budget for reasoning models
CYPHER_SERVICE_ACCOUNT_FILE Path to service account file (for Vertex AI)

System Settings

Variable Default Description
GRAPH_BACKEND sqlite Graph engine: sqlite (embedded, no server), memgraph or neo4j. Memgraph needs the memgraph extra (uv pip install 'code-graph-rag[memgraph]') and the bundled stack (cgr daemon up); Neo4j needs the neo4j extra and is configured with the NEO4J_* variables below, and a Neo4j server is yours to run. See Graph Backends.
SQLITE_GRAPH_PATH $CGR_HOME/graph.sqlite The embedded graph's file, shared by every indexed project as one Memgraph instance is
CGR_VECTOR_STORE_BACKEND sqlite Where semantic search keeps its vectors: sqlite, a file needing no server (sqlite-vec, in the semantic extra), qdrant or milvus (the milvus extra). See Semantic Search.
SQLITE_VECTOR_PATH $CGR_HOME/vectors.sqlite The sqlite vector store's file, beside the embedded graph's
MEMGRAPH_HOST localhost Memgraph hostname
MEMGRAPH_PORT 7687 Memgraph port
MEMGRAPH_HTTP_PORT 7444 Memgraph HTTP port
LAB_PORT 3000 Memgraph Lab port
MEMGRAPH_BATCH_SIZE 1000 Batch size for Memgraph operations; at least 1, as for --batch-size
NEO4J_URI bolt://localhost:7687 Neo4j connection URI. The scheme selects routing (neo4j:// for a cluster, bolt:// for a single instance) and TLS (+s/+ssc).
NEO4J_USERNAME (unset) Neo4j username; leave unset for an unauthenticated server
NEO4J_PASSWORD (unset) Neo4j password
NEO4J_DATABASE neo4j Neo4j database name
TARGET_REPO_PATH . Default repository path
CGR_HOME ~/.cgr cgr's own directory: the bundled stack, workspaces, and each checkout's sync and edit state under state/ (hash cache, exclusion stamp, parser fingerprint, edit history), which is kept out of the indexed repository. See cgr's own state.
CPP_FRONTEND hybrid C/C++ frontend mode: treesitter, libclang, or hybrid. The libclang-backed modes require the cpp extra and a compilation database.
CSHARP_FRONTEND treesitter C# frontend mode: treesitter, auto, hybrid, or roslyn. With dotnet on PATH, auto resolves to hybrid, and hybrid/roslyn run the Roslyn path: dotnet restore evaluates the analysed repository's MSBuild files, and its source generators execute. Without dotnet, all three fall back to treesitter (auto logs an info message; an explicit hybrid or roslyn logs a warning). Select a Roslyn-backed mode only for repositories you trust. See the graph schema documentation.
GO_FRONTEND auto Go frontend mode: auto, treesitter, or gotypes. With Go 1.27.2 or newer on PATH, auto and gotypes add go/types call and IMPLEMENTS facts on top of Tree-sitter. An older Go logs one warning naming the version it found and falls back to treesitter; a helper that failed to build is not rebuilt on every sync, only an hour later or as soon as Go, a GO* environment variable the build reads or the helper changes. The helper is built with GOWORK=off and no GOFLAGS flag but -modcacherw, set in the environment or by go env -w, since the others are meant for your module.
WEB_SEARCH_PROVIDER duckduckgo Web-search backend: keyless duckduckgo or serpdive. The web-search tool is registered by default, so searches can send query text to the selected external provider even when this variable is unset.
SERPDIVE_API_KEY (unset) API key used when WEB_SEARCH_PROVIDER=serpdive; without one, web search falls back to DuckDuckGo.
CGR_CAPTURE (unset) What an index writes to the graph, as capture group tokens separated by commas, semicolons or spaces: a group or relationship type adds (io, +HAS_PARAMETER), -NAME drops (-calls), and all or none replaces the selection (none,structure). Unset, an index holds only the default groups. Read by every indexing run; --capture on cgr start and cgr index applies after it. The groups, their defaults and what each adds: Capture Groups.
CGR_INDEX_ENGINE auto Which engine indexes each language, as tokens separated by commas, semicolons or spaces: an engine on its own (auto, python or rust) sets every language, and LANGUAGE=ENGINE sets one (python,go=rust), the language being one of python, javascript, typescript, tsx, rust, go, scala, java, c, cpp, php, lua, c_sharp, dart, sql, julia or lean. auto is the engine this release runs each language on. javascript, typescript and tsx take one engine together, as do c and cpp. This release indexes every language on Python: a language asked for on Rust indexes on Python, with a warning when the value names it. An invalid value is refused at start-up, like any invalid setting.
CGR_CAPTURE_LOCAL_DEFINITIONS true Capture methods of classes defined inside function bodies (function-local definitions). On by default for exhaustive structure capture; set to false to keep the graph free of throwaway helpers and test mocks.
CGR_CONTEXT_COMPACTION_ENABLED true Drop old tool output once the context passes the critical threshold, keeping a long session inside the model's window. Set to false to keep every tool result and accept the ceiling instead; the agent prints a notice whenever it compacts.
CGR_SPONSOR_PLEDGE true After a command finishes in a terminal, print one dimmed line on stderr pointing to the project's GitHub Sponsors page. It never appears when stderr is not a terminal, after cgr help or cgr mcp-server, or under --quiet; set to false to drop it while keeping the rest of the output.
CGR_TRUST_PROJECT_INSTRUCTIONS false Load every repository's .cgr.md without asking. By default a repository's .cgr.md reaches the agent's system prompt only after you approve its current content in an interactive session, and a changed file is shown again; see Project instructions. Set to true only for CI on repositories you control. Read only from the environment cgr starts with: a .env in the working directory cannot set it, since that file usually belongs to the repository being analysed.
CGR_ALLOW_SENSITIVE_READS false Let MCP read_file serve files that look like credentials (.env, private keys, .git/config, Terraform state). The CLI agent asks before reading one instead. Like CGR_TRUST_PROJECT_INSTRUCTIONS, read only from the environment cgr starts with, never from .env. See Credential files.
CGR_ALLOW_SENSITIVE_WRITES false Let MCP write_file and surgical_replace_code change files that look like credentials (the same list CGR_ALLOW_SENSITIVE_READS uses). Files inside .git are never written, whatever this says. Read only from the environment cgr starts with, never from .env. See Credential files.
MCP_READ_ONLY false Serve only the MCP tools that read, the same as cgr mcp-server --read-only.
OLLAMA_BASE_URL http://localhost:11434 Base URL for the local Ollama server (/v1 is appended for the OpenAI-compatible endpoint)

Setting Up Ollama

curl -fsSL https://ollama.ai/install.sh | sh

ollama pull qwen2.5-coder
# Or try other models:
# ollama pull deepseek-r1

Ollama automatically starts serving on localhost:11434.

!!! note Local models provide privacy and no API costs, but may have lower accuracy compared to cloud models like Gemini or GPT-5.6.

Programmatic Configuration

You can also configure providers programmatically via the Python SDK:

from cgr import settings

settings.set_orchestrator("openai", "gpt-5.6-terra", api_key="sk-...")
settings.set_cypher("google", "gemini-3.5-flash-lite", api_key="your-key")

The programmatic configuration snippet run in a Python REPL, showing the active orchestrator and Cypher configs change