> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# Configuring Custom Initialization

> Use config.py to register custom LLM providers, embedding providers, and shared resources at startup.

The `config.py` file contains initialization code that runs once at startup, before the `LLMRails` instance is fully initialized. Use it to register custom providers and set up shared resources.

## When to Use config.py or actions.py

| Use Case                           | File         | Reason                                     |
| ---------------------------------- | ------------ | ------------------------------------------ |
| Register custom LLM provider       | `config.py`  | Must happen before LLMRails initialization |
| Register custom embedding provider | `config.py`  | Must happen before LLMRails initialization |
| Initialize database connection     | `config.py`  | Shared resource, initialized once          |
| Validate user input                | `actions.py` | Called during request processing           |
| Call external API                  | `actions.py` | Called during request processing           |
| Custom guardrail logic             | `actions.py` | Called from Colang flows                   |

## Configuration Sections

Define the init() function to initialize resources and register action parameters at startup.

How To

Register custom text completion and chat models. Use the `LLMModel` Protocol for the built-in client, or LangChain `BaseLLM`/`BaseChatModel` when running with `NEMOGUARDRAILS_LLM_FRAMEWORK=langchain`.

How To

Implement the LLMModel protocol to connect a non-OpenAI-compatible backend to the NVIDIA NeMo Guardrails library without depending on LangChain.

How To

Replace the LLM framework layer to connect LiteLLM, an in-house orchestrator, or any non-default LLM stack to the NVIDIA NeMo Guardrails library.

How To

Register custom embedding providers for vector similarity search in the NVIDIA NeMo Guardrails library.

How To

Pass and access custom data from config.yml in your initialization code and actions.

How To

## Related Topics

* [Custom Actions](/configure-guardrails/actions) - Define callable actions in `actions.py`
* [Model Configuration](/configure-guardrails/yaml-schema/model-configuration) - Configure LLM models in `config.yml`