Skip to content

create_config

relationalai.config.config
create_config(**data) -> Config

Load configuration programmatically or from the highest-priority available config file source.

If keyword arguments are provided, this creates a RAIConfig from those values. Otherwise, it tries config sources in order (first match wins):

  1. RAI_CONFIG_FILE_PATH env var — explicit path, skips all auto-discovery
  2. raiconfig.yaml / raiconfig.yml (searched upward from current directory)
  3. raiconfig.toml (deprecated)
  4. ~/.snowflake/config.toml
  5. ~/.dbt/profiles.yml

If a source file is found but invalid, an error is raised immediately (no fallback).

  • **data

    (Any, default: {}) - Programmatic configuration values, passed as keyword arguments.

    Supported public keys are:

    • connections: A dict of connection definitions; see config.connections.ConnectionConfig for supported connection types and fields. (required)
    • default_connection: str (optional; auto-selected when exactly one connection exists)
    • profile / profiles: dict of named overrides (e.g., dev, prod) applied on top of the base config when selected (YAML key is profile)
    • active_profile: str (optional; selects which profile override to apply)
    • execution: dict of ExecutionConfig fields
    • data: dict of DataConfig fields
    • compiler: dict of CompilerConfig fields
    • model: dict of ModelConfig fields
    • reasoners: dict of ReasonersConfig fields
    • debug: dict of DebugConfig fields
    • jobs: dict of JobsConfig fields

    The following keys are also supported, but are not intended for use by end users and should only be set if instructed to do so by RelationalAI support:

    • use_graph_index: bool, optional (default: True)
    • install_mode: bool, optional (default: False)
    • enable_otel_handler: bool, optional (default: False)
  • Config - A validated config instance.

Loading from a config file (auto-discovered):

>>> from relationalai.config import create_config
>>> cfg = create_config()

Programmatic Snowflake config using browser-based auth:

>>> from relationalai.config import create_config
>>> cfg = create_config(
... connections={
... "sf": {
... "type": "snowflake",
... "authenticator": "externalbrowser",
... "account": "my_account",
... "warehouse": "my_warehouse",
... "user": "my_user",
... }
... }
... )
>>> cfg.default_connection
'sf'

See snowflake for more Snowflake connection examples.

Programmatic DuckDB config:

>>> cfg = create_config(connections={"db": {"type": "duckdb", "path": ":memory:"}})
>>> cfg.default_connection
'db'
RelationalAI Documentation
├──  Build With RelationalAI
│   └──  Understand how PyRel works
│       ├──  PyRel configuration overview
│       │   ├──  Overview
│       │   │   └──  How validation works
│       │   └──  Create configuration in code
│       │       ├──  Create a Config instance
│       │       └──  Override file-based configuration with programmatic config
│       └──  Build a semantic model
│           └──  Create a model instance
│               └──  Configure a model’s connection
└──  Release Notes
    └──  Python API Release Notes
        ├──  What’s New in Version 1.0.2
        │   └──  Bug Fixes
        ├──  What’s New in Version 1.0.3
        │   └──  New Features and Enhancements
        └──  What’s New in Version 1.0.5