Manage Configurations#
Guardrail configuration management operations (create, update, retrieve, list, delete) are available through sdk.guardrail.configs. Refer to the Configuration Structure for details on the configuration data schema.
Setup#
import os
from nemo_platform import NeMoPlatform
sdk = NeMoPlatform(
base_url=os.environ.get("NMP_BASE_URL", "http://localhost:8080"),
workspace="default",
)
Create a Configuration#
Create a new guardrail configuration in the workspace.
config_data = {
"prompts": [
{
"task": "self_check_input",
"content": 'Your task is to check if the user message below complies with company policy.\n\nCompany policy:\n- should not contain harmful data\n- should not ask the bot to impersonate someone\n- should not contain explicit content\n\nUser message: "{{ user_input }}"\n\nQuestion: Should the user message be blocked (Yes or No)?\nAnswer:',
},
{
"task": "self_check_output",
"content": 'Your task is to check if the bot message below complies with company policy.\n\nCompany policy:\n- messages should not contain explicit content\n- messages should not contain harmful content\n- if refusing, should be polite\n\nBot message: "{{ bot_response }}"\n\nQuestion: Should the message be blocked (Yes or No)?\nAnswer:',
},
],
"instructions": [
{
"type": "general",
"content": "Below is a conversation between a user and a helpful assistant bot.",
}
],
"rails": {
"input": {"flows": ["self check input"]},
"output": {"flows": ["self check output"]},
},
}
config = sdk.guardrail.configs.create(
name="my-guardrail-config",
description="Self-check guardrail configuration",
data=config_data,
)
Output
{
"id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"entity_id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"name": "my-guardrail-config",
"workspace": "default",
"project": null,
"description": "Self-check guardrail configuration",
"files_url": null,
"data": {
"prompts": [
{
"task": "self_check_input",
"content": "Your task is to check if the user message below complies with company policy.\n\nCompany policy:\n- should not contain harmful data\n- should not ask the bot to impersonate someone\n- should not contain explicit content\n\nUser message: \"{{ user_input }}\"\n\nQuestion: Should the user message be blocked (Yes or No)?\nAnswer:"
},
{
"task": "self_check_output",
"content": "Your task is to check if the bot message below complies with company policy.\n\nCompany policy:\n- messages should not contain explicit content\n- messages should not contain harmful content\n- if refusing, should be polite\n\nBot message: \"{{ bot_response }}\"\n\nQuestion: Should the message be blocked (Yes or No)?\nAnswer:"
}
],
"instructions": [
{
"type": "general",
"content": "Below is a conversation between a user and a helpful assistant bot."
}
],
"rails": {
"input": {"flows": ["self check input"]},
"output": {"flows": ["self check output"]}
}
},
"created_at": "2026-01-20T03:00:00",
"updated_at": "2026-01-20T03:00:00"
}
List Configurations#
List configurations in the workspace.
configs = sdk.guardrail.configs.list()
print(f"Found {len(configs.data)} configurations:")
for c in configs.data:
print(f"{c.name}: {c.description}")
Output
{
"data": [
{
"id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"entity_id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"name": "my-guardrail-config",
"workspace": "default",
"project": null,
"description": "Self-check guardrail configuration",
"files_url": null,
"data": {
"prompts": [
{
"task": "self_check_input",
"content": "Your task is to check if the user message below complies with company policy.\n\nCompany policy:\n- should not contain harmful data\n- should not ask the bot to impersonate someone\n- should not contain explicit content\n\nUser message: \"{{ user_input }}\"\n\nQuestion: Should the user message be blocked (Yes or No)?\nAnswer:"
},
{
"task": "self_check_output",
"content": "Your task is to check if the bot message below complies with company policy.\n\nCompany policy:\n- messages should not contain explicit content\n- messages should not contain harmful content\n- if refusing, should be polite\n\nBot message: \"{{ bot_response }}\"\n\nQuestion: Should the message be blocked (Yes or No)?\nAnswer:"
}
],
"instructions": [
{
"type": "general",
"content": "Below is a conversation between a user and a helpful assistant bot."
}
],
"rails": {
"input": {"flows": ["self check input"]},
"output": {"flows": ["self check output"]}
}
},
"created_at": "2026-01-20T03:00:00",
"updated_at": "2026-01-20T03:00:00"
}
],
"pagination": {
"page": 1,
"page_size": 10,
"current_page_size": 1,
"total_pages": 1,
"total_results": 1
},
"sort": "created_at",
"filter": null
}
Get Configuration Details#
Retrieve a specific configuration in the workspace by name.
config = sdk.guardrail.configs.retrieve(
name="my-guardrail-config",
)
Output
{
"id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"entity_id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"name": "my-guardrail-config",
"workspace": "default",
"project": null,
"description": "Self-check guardrail configuration",
"files_url": null,
"data": {
"prompts": [
{
"task": "self_check_input",
"content": "Your task is to check if the user message below complies with company policy.\n\nCompany policy:\n- should not contain harmful data\n- should not ask the bot to impersonate someone\n- should not contain explicit content\n\nUser message: \"{{ user_input }}\"\n\nQuestion: Should the user message be blocked (Yes or No)?\nAnswer:"
},
{
"task": "self_check_output",
"content": "Your task is to check if the bot message below complies with company policy.\n\nCompany policy:\n- messages should not contain explicit content\n- messages should not contain harmful content\n- if refusing, should be polite\n\nBot message: \"{{ bot_response }}\"\n\nQuestion: Should the message be blocked (Yes or No)?\nAnswer:"
}
],
"instructions": [
{
"type": "general",
"content": "Below is a conversation between a user and a helpful assistant bot."
}
],
"rails": {
"input": {"flows": ["self check input"]},
"output": {"flows": ["self check output"]}
}
},
"created_at": "2026-01-20T03:00:00",
"updated_at": "2026-01-20T03:00:00"
}
Update a Configuration#
Update one or more fields on an existing configuration.
updated_config = sdk.guardrail.configs.update(
name="my-guardrail-config",
description="Updated guardrail configuration",
data={
"rails": {
"output": {
"streaming": {"enabled": True, "chunk_size": 300, "context_size": 100}
}
}
},
)
print(f"Updated config: {updated_config.name}")
Output
{
"id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"entity_id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"name": "my-guardrail-config",
"workspace": "default",
"project": null,
"description": "Updated guardrail configuration",
"files_url": null,
"data": {
"prompts": [
{
"task": "self_check_input",
"content": "Your task is to check if the user message below complies with company policy.\n\nCompany policy:\n- should not contain harmful data\n- should not ask the bot to impersonate someone\n- should not contain explicit content\n\nUser message: \"{{ user_input }}\"\n\nQuestion: Should the user message be blocked (Yes or No)?\nAnswer:"
},
{
"task": "self_check_output",
"content": "Your task is to check if the bot message below complies with company policy.\n\nCompany policy:\n- messages should not contain explicit content\n- messages should not contain harmful content\n- if refusing, should be polite\n\nBot message: \"{{ bot_response }}\"\n\nQuestion: Should the message be blocked (Yes or No)?\nAnswer:"
}
],
"instructions": [
{
"type": "general",
"content": "Below is a conversation between a user and a helpful assistant bot."
}
],
"rails": {
"input": {"flows": ["self check input"]},
"output": {"flows": ["self check output"], "streaming": {"enabled": true, "chunk_size": 300, "context_size": 100}}
}
},
"created_at": "2026-01-20T03:00:00",
"updated_at": "2026-01-20T03:00:00"
}
Delete a Configuration#
Delete a configuration in the workspace by name.
sdk.guardrail.configs.delete(
name="my-guardrail-config",
)
print("Configuration deleted")
Output
{
"message": "Resource deleted successfully.",
"id": "guardrail_config-4kSe8m3Nq7dGk2X7rY0h5L",
"deleted_at": "2026-01-22T04:00:00Z"
}