Skip to content

create_config

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

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.

  • **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'

Referenced By

RelationalAI Documentation
├──  Build With RelationalAI
│   └──  Understand how PyRel works
│       ├──  Configure PyRel
│       │   ├──  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
├──  Manage the RAI Native App for Snowflake
│   ├──  Manage the RelationalAI Native App for Snowflake
│   │   ├──  View the Native App’s Status
│   │   │   ├──  Check that the RAI service is running
│   │   │   └──  Check whether startup is still in progress
│   │   └──  Shut down the app
│   │       ├──  Stop the app and suspend resources
│   │       ├──  Stop the app and remove the SPCS service
│   │       └──  Stop the app and drop all managed resources
│   ├──  Manage data sources
│   │   ├──  Enable the CDC service
│   │   │   ├──  Resize the CDC engine
│   │   │   └──  Disable the CDC service
│   │   ├──  Manage data streams
│   │   │   ├──  View all data streams
│   │   │   └──  View details for one data stream
│   │   └──  Fix data stream issues
│   │       └──  Fix quarantined streams
│   └──  Get started with the RAI Native App for Snowflake
│       └──  Start the app
│           └──  Call the activation procedure to start the app
└──  Release Notes
    └──  Python API Release Notes
        ├──  What’s New in Version 1.0.18
        │   └──  New Features and Enhancements
        ├──  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