Skip to content

Commit e943d4c

Browse files
feat: Update Trend Micro Vision One AI Guard official endpoint
1 parent 2f74cb6 commit e943d4c

6 files changed

Lines changed: 77 additions & 14 deletions

File tree

docs/user-guides/community/trend-micro.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ Trend Micro Vision One [AI Application Security's](https://docs.trendmicro.com/e
2020
rails:
2121
config:
2222
trend_micro:
23-
v1_url: "https://api.xdr.trendmicro.com/beta/aiSecurity/guard" # Replace this with your AI Guard URL
23+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails" # Trend Micro AI Guard Endpoint
2424
api_key_env_var: "V1_API_KEY"
25+
application_name: "my-ai-app" # Required: Application identifier (max 64 chars, alphanumeric, hyphens, underscores)
26+
# Optional:
27+
detailed_response: true # Set to true for detailed AI Guard results
28+
# For other regions, use: https://api.{region}.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
29+
# where region is: eu, jp, au, in, sg, or mea
2530
input:
2631
flows:
2732
- trend ai guard input
@@ -37,8 +42,13 @@ colang_version: "2.x"
3742
rails:
3843
config:
3944
trend_micro:
40-
v1_url: "https://api.xdr.trendmicro.com/beta/aiSecurity/guard" # Replace this with your AI Guard URL
45+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails" # Trend Micro AI Guard Endpoint
4146
api_key_env_var: "V1_API_KEY"
47+
application_name: "my-ai-app" # Required: Application identifier (max 64 chars, alphanumeric, hyphens, underscores)
48+
# Optional:
49+
detailed_response: true # Set to true for detailed AI results
50+
# For other regions, use: https://api.{region}.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
51+
# where region is: eu, jp, au, in, sg, or mea
4252
```
4353
```
4454
# rails.co

examples/configs/trend_micro/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,26 @@ instructions:
1313
rails:
1414
config:
1515
trend_micro:
16+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails"
17+
18+
# Trend Micro Vision One API key environment variable
1619
api_key_env_var: "V1_API_KEY"
20+
21+
# Application name
22+
# Must be alphanumeric with hyphens/underscores, max 64 characters
23+
application_name: "nemo-guardrails-demo"
24+
25+
# Optional: Set to true for detailed AI Guard results with confidence scores
26+
detailed_response: false
27+
28+
# For other regions, update v1_url to:
29+
# EU: https://api.eu.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
30+
# JP: https://api.jp.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
31+
# AU: https://api.au.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
32+
# IN: https://api.in.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
33+
# SG: https://api.sg.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
34+
# MEA: https://api.mea.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails
35+
1736
input:
1837
flows:
1938
- trend ai guard input

examples/configs/trend_micro_v2/config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ enable_rails_exceptions: True
55
rails:
66
config:
77
trend_micro:
8+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails"
9+
10+
# Trend Micro Vision One API key environment variable
811
api_key_env_var: "V1_API_KEY"
912

13+
# Application name
14+
application_name: "nemo-guardrails-demo-v2"
15+
16+
# Optional: Set to true for detailed AI Guard results
17+
detailed_response: false
18+
1019
models:
1120
- type: main
1221
engine: openai

nemoguardrails/library/trend_micro/actions.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class Guard(BaseModel):
3333
Represents a guard entity with a single string attribute.
3434
3535
Attributes:
36-
guard (str): The input text for guard analysis.
36+
prompt (str): The input text for AI guard analysis.
3737
"""
3838

39-
guard: str
39+
prompt: str
4040

4141

4242
class GuardResult(BaseModel):
@@ -93,7 +93,7 @@ def trend_ai_guard_mapping(result: GuardResult) -> bool:
9393
@action(is_system_action=True, output_mapping=trend_ai_guard_mapping)
9494
async def trend_ai_guard(config: RailsConfig, text: Optional[str] = None):
9595
"""
96-
Custom action to invoke the Trend Ai Guard
96+
Custom action to invoke the Trend Micro AI Guard API.
9797
"""
9898

9999
trend_config = get_config(config)
@@ -109,16 +109,28 @@ async def trend_ai_guard(config: RailsConfig, text: Optional[str] = None):
109109
reason="Trend Micro Vision One API Key not found",
110110
)
111111

112+
app_name = trend_config.application_name
113+
112114
async with httpx.AsyncClient() as client:
113-
data = Guard(guard=text).model_dump()
115+
data = Guard(prompt=text).model_dump()
116+
117+
# Build headers with required TMV1-Application-Name
118+
headers = {
119+
"Authorization": f"Bearer {v1_api_key}",
120+
"Content-Type": "application/json",
121+
"TMV1-Application-Name": app_name,
122+
}
123+
124+
# Add Prefer header for detail level control
125+
if trend_config.detailed_response:
126+
headers["Prefer"] = "return=representation"
127+
else:
128+
headers["Prefer"] = "return=minimal"
114129

115130
response = await client.post(
116131
v1_url,
117132
content=to_json(data),
118-
headers={
119-
"Authorization": f"Bearer {v1_api_key}",
120-
"Content-Type": "application/json",
121-
},
133+
headers=headers,
122134
)
123135

124136
try:

nemoguardrails/rails/llm/config.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,15 +848,26 @@ class TrendMicroRailConfig(BaseModel):
848848
"""Configuration data for the Trend Micro AI Guard API"""
849849

850850
v1_url: Optional[str] = Field(
851-
default="https://api.xdr.trendmicro.com/beta/aiSecurity/guard",
852-
description="The endpoint for the Trend Micro AI Guard API",
851+
default="https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails",
852+
description="The endpoint for the Trend Micro AI Guard API. For other regions, use: https://api.{region}.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails where region is eu, jp, au, in, sg, or mea.",
853853
)
854854

855855
api_key_env_var: Optional[str] = Field(
856856
default=None,
857857
description="Environment variable containing API key for Trend Micro AI Guard",
858858
)
859859

860+
application_name: str = Field(
861+
default="nemo-guardrails",
862+
description="Application name for TMV1-Application-Name header (REQUIRED). Must contain only letters, numbers, hyphens, and underscores, with a maximum length of 64 characters.",
863+
max_length=64,
864+
)
865+
866+
detailed_response: Optional[bool] = Field(
867+
default=False,
868+
description="If True, returns detailed AI Guard results with confidence scores (Prefer: return=representation). If False, returns minimal response with only action and reasons (Prefer: return=minimal).",
869+
)
870+
860871
def get_api_key(self) -> Optional[str]:
861872
"""Helper to return an API key (if it exists) from a Trend Micro configuration.
862873
The `api_key_env_var` field, a string stored in this environment variable.

tests/test_trend_ai_guard.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
rails:
2626
config:
2727
trend_micro:
28-
v1_url: "https://api.xdr.trendmicro.com/beta/aiSecurity/guard"
28+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails"
2929
api_key_env_var: "V1_API_KEY"
30+
application_name: "test-app"
3031
input:
3132
flows:
3233
- trend ai guard input
@@ -38,8 +39,9 @@
3839
rails:
3940
config:
4041
trend_micro:
41-
v1_url: "https://api.xdr.trendmicro.com/beta/aiSecurity/guard"
42+
v1_url: "https://api.xdr.trendmicro.com/v3.0/aiSecurity/applyGuardrails"
4243
api_key_env_var: "V1_API_KEY"
44+
application_name: "test-app"
4345
output:
4446
flows:
4547
- trend ai guard output

0 commit comments

Comments
 (0)