Skip to content

create_config

relationalai.config.config
create_config(
*,
snowflake_session: "snowflake.snowpark.Session | None" = None,
validate_references: bool = True,
**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

Project-level (searched upward from the current directory):

  1. raiconfig.yaml / raiconfig.yml
  2. raiconfig.toml (deprecated)

Global (home directory):

  1. ~/.rai/raiconfig.yaml / ~/.rai/raiconfig.yml — shared connections, etc.
  2. ~/.snowflake/config.toml
  3. ~/.dbt/profiles.yml

Discovery merges the available sources (most-specific wins): a project raiconfig.yaml layers over ~/.rai/raiconfig.yaml, which layers over ~/.snowflake and ~/.dbt.

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

Parameters

  • snowflake_session

    (snowflake.snowpark.Session, default: None) - A pre-built Snowpark session to use for all Snowflake operations. When provided, it takes priority over the resolved Snowflake connection’s own session (skipping get_active_session() and credential-based session creation). Useful for thread-safe usage, since Snowpark sessions are not thread-safe — each thread can build and inject its own session.

  • validate_references

    (bool, default: True) - When True (default), fail with a clear error if active_profile, default_connection, or a reasoner connection names something not defined in the merged config. Set False to load a config with broken references anyway (used by diagnostics like rai doctor, which need to inspect invalid configs).

  • **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)
    • enable_otel_handler: bool, optional (default: False)

Returns

  • Config - A validated config instance.

Raises

Examples

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'