> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/llms.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 #### [Init Function](/configure-guardrails/custom-initialization/init-function) Define the init() function to initialize resources and register action parameters at startup. How To #### [LLM Providers](/configure-guardrails/custom-initialization/custom-llm-providers) 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 #### [Custom LLM Model](/configure-guardrails/custom-initialization/custom-llm-model) Implement the LLMModel protocol to connect a non-OpenAI-compatible backend to the NVIDIA NeMo Guardrails library without depending on LangChain. How To #### [Custom LLM Framework](/configure-guardrails/custom-initialization/custom-llm-framework) 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 #### [Embedding Providers](/configure-guardrails/custom-initialization/custom-embedding-providers) Register custom embedding providers for vector similarity search in the NVIDIA NeMo Guardrails library. How To #### [Custom Data](/configure-guardrails/custom-initialization/custom-data) 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` > Use config.py to register custom LLM providers, embedding providers, and shared resources at startup. ## Docs - [The Init Function for NeMo Guardrails](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/init-function.md): Define the init() function to initialize resources and register action parameters at startup. - [Custom LLM Providers for NeMo Guardrails](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/custom-llm-providers.md): Register LangChain BaseLLM and BaseChatModel providers under the LangChain framework path (requires NEMOGUARDRAILS_LLM_FRAMEWORK=langchain). - [Custom LLM Models for the NVIDIA NeMo Guardrails library](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/custom-llm-model.md): Implement the LLMModel protocol to connect a non-OpenAI-compatible backend to the NVIDIA NeMo Guardrails library without depending on LangChain. - [Testing Your Guardrails Configuration](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/testing-your-config.md): Write fast, deterministic tests for your NeMo Guardrails configuration using the public testing surface. - [Custom LLM Frameworks for the NVIDIA NeMo Guardrails library](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/custom-llm-framework.md): Replace the LLM framework layer to connect LiteLLM, an in-house orchestrator, or any non-default LLM stack to the NVIDIA NeMo Guardrails library. - [Custom Embedding Providers for NeMo Guardrails](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/custom-embedding-providers.md): Register custom embedding providers for vector similarity search in NeMo Guardrails. - [Custom Configuration Data for NeMo Guardrails](https://docs.nvidia.com/nemo/guardrails/v0.24.1/configure-guardrails/custom-initialization/custom-data.md): Pass and access custom data from config.yml in your initialization code and actions.