Skip to content

Commit 4cb0992

Browse files
authored
Merge branch 'main' into adb-fixes
2 parents 7aef142 + ad74d21 commit 4cb0992

3 files changed

Lines changed: 149 additions & 6 deletions

File tree

content/docs/kubernetes/main/llm/guardrails/bedrock-guardrails.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Langua
5555
apiVersion: {{< reuse "agw-docs/snippets/api-version.md" >}}
5656
kind: {{< reuse "agw-docs/snippets/policy.md" >}}
5757
metadata:
58-
name: openai-prompt-guard
58+
name: bedrock-prompt-guard
5959
namespace: {{< reuse "agw-docs/snippets/namespace.md" >}}
6060
spec:
6161
targetRefs:
@@ -69,7 +69,7 @@ AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Langua
6969
- bedrockGuardrails:
7070
identifier: <guardrail-ID>
7171
version: "<version>"
72-
region: <region>>
72+
region: <region>
7373
policies:
7474
auth:
7575
aws:
@@ -79,7 +79,7 @@ AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Langua
7979
- bedrockGuardrails:
8080
identifier: <guardrail-ID>
8181
version: "<version>"
82-
region: <region>>
82+
region: <region>
8383
policies:
8484
auth:
8585
aws:
@@ -92,6 +92,8 @@ AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Langua
9292
The `aws: {}` configuration uses the default AWS credential chain (IAM role, environment variables, or instance profile). For authentication details, see the [AWS authentication documentation](https://docs.aws.amazon.com/sdk-for-go/api/aws/session/).
9393
{{< /callout >}}
9494

95+
The `policies` field supports more than the `aws` credential source shown here. You can choose a different authentication method or tune the connection that agentgateway opens to Bedrock, such as setting a request timeout or custom TLS. For all the options, see [Backend connection and authentication policies](#backend-connection-and-authentication-policies).
96+
9597

9698
5. Test the guardrail. The following commands assume that you set up your guardrail to block requests that contain email information.
9799
{{< tabs >}}
@@ -156,12 +158,56 @@ AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Langua
156158
The request was rejected due to inappropriate content
157159
```
158160

161+
## Backend connection and authentication policies
162+
163+
The `policies` field configures how agentgateway connects and authenticates to the AWS Bedrock Guardrails service when it evaluates a request or response.
164+
165+
### Authentication
166+
167+
Under `policies.auth`, set one credential source (`aws`, `secretRef`, or `key`). Optionally, set `location` to control where the credential is placed.
168+
169+
| Method | Description |
170+
| -- | -- |
171+
| `aws` | Authenticate with AWS credentials. Set `aws: {}` to use the default AWS credential chain (IAM role, environment variables, or instance profile), or set `aws.secretRef` to read credentials from a Kubernetes secret. |
172+
| `secretRef` | Read the API key from a Kubernetes secret. By default, the key that matches the credential location is used, such as `Authorization` for the default header location. To use a different key, set `secretRef.key`. |
173+
| `key` | Send an inline API key in the `Authorization` header. This option is the least secure. Use a secret instead when possible. |
174+
| `location` | Where to place the credential. Defaults to the `Authorization` header with a `Bearer` prefix. To change it, set a `header`, `queryParameter`, or `cookie`. |
175+
176+
### Backend connection settings
177+
178+
You can also tune the connection that agentgateway opens to the Bedrock Guardrails backend by setting the following `BackendConnectionPolicy` fields under `policies`.
179+
180+
| Setting | Description |
181+
| -- | -- |
182+
| `tls` | TLS settings for the connection, such as a custom CA certificate or SNI. |
183+
| `http` | HTTP settings, such as the `requestTimeout` and HTTP protocol `version`. |
184+
| `tcp` | TCP connection settings. |
185+
| `tunnel` | Tunnel settings, such as an `HTTPS_PROXY`, used to reach the backend. |
186+
187+
For example, the following prompt guard authenticates with a secret and sets a request timeout for the calls to Bedrock.
188+
189+
```yaml
190+
- bedrockGuardrails:
191+
identifier: <guardrail-ID>
192+
version: "<version>"
193+
region: <region>
194+
policies:
195+
auth:
196+
aws:
197+
secretRef:
198+
name: aws-secret
199+
http:
200+
requestTimeout: 5s
201+
```
202+
203+
For the full set of fields, see the [API reference]({{< link-hextra path="/reference/api/" >}}).
204+
159205
## Cleanup
160206
161207
{{< reuse "agw-docs/snippets/cleanup.md" >}}
162208
163209
```sh
164-
kubectl delete {{< reuse "agw-docs/snippets/policy.md" >}} openai-prompt-guard -n {{< reuse "agw-docs/snippets/namespace.md" >}}
210+
kubectl delete {{< reuse "agw-docs/snippets/policy.md" >}} bedrock-prompt-guard -n {{< reuse "agw-docs/snippets/namespace.md" >}}
165211
kubectl delete secret aws-secret -n {{< reuse "agw-docs/snippets/namespace.md" >}}
166212
```
167213

content/docs/kubernetes/main/llm/guardrails/google-model-armor.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ In your GKE cluster, set up workload identity.
178178
promptGuard:
179179
request:
180180
- googleModelArmor:
181-
templateId: <template-ID
181+
templateId: <template-ID>
182182
projectId: <project-ID>
183183
location: <location>
184184
policies:
@@ -187,7 +187,7 @@ In your GKE cluster, set up workload identity.
187187
type: AccessToken
188188
response:
189189
- googleModelArmor:
190-
templateId: <template-ID
190+
templateId: <template-ID>
191191
projectId: <project-ID>
192192
location: <location>
193193
policies:
@@ -197,6 +197,8 @@ In your GKE cluster, set up workload identity.
197197
EOF
198198
```
199199

200+
The `policies` field supports more than the `gcp` authentication shown here. You can also tune the connection that agentgateway opens to Model Armor, such as setting a request timeout or custom TLS. For all the options, see [Backend connection and authentication policies](#backend-connection-and-authentication-policies).
201+
200202
2. Send a request to the Gemini provider that triggers the guardrail.
201203
{{< tabs >}}
202204
{{% tab name="Gemini default" %}}
@@ -269,3 +271,56 @@ In your GKE cluster, set up workload identity.
269271
The request was rejected due to inappropriate content
270272
```
271273

274+
## Backend connection and authentication policies
275+
276+
The `policies` field configures how agentgateway connects and authenticates to Google Model Armor when it evaluates a request or response.
277+
278+
### Authentication
279+
280+
Under `policies.auth`, set the credential source.
281+
282+
| Method | Description |
283+
| -- | -- |
284+
| `gcp` | Authenticate with GCP credentials. Set `gcp: {}` to use the default Google credential discovery, or set the credential `type` to use, such as `AccessToken`. |
285+
286+
### Backend connection settings
287+
288+
You can also tune the connection that agentgateway opens to the Model Armor backend by setting the following `BackendConnectionPolicy` fields under `policies`.
289+
290+
| Setting | Description |
291+
| -- | -- |
292+
| `tls` | TLS settings for the connection, such as a custom CA certificate or SNI. |
293+
| `http` | HTTP settings, such as the `requestTimeout` and HTTP protocol `version`. |
294+
| `tcp` | TCP connection settings. |
295+
| `tunnel` | Tunnel settings, such as an `HTTPS_PROXY`, used to reach the backend. |
296+
297+
For example, the following prompt guard sets a request timeout for the calls to Model Armor.
298+
299+
```yaml
300+
- googleModelArmor:
301+
templateId: <template-ID>
302+
projectId: <project-ID>
303+
location: <location>
304+
policies:
305+
auth:
306+
gcp:
307+
type: AccessToken
308+
http:
309+
requestTimeout: 5s
310+
```
311+
312+
For the full set of fields, see the [API reference]({{< link-hextra path="/reference/api/" >}}).
313+
314+
## Cleanup
315+
316+
{{< reuse "agw-docs/snippets/cleanup.md" >}}
317+
318+
```sh
319+
kubectl delete {{< reuse "agw-docs/snippets/policy.md" >}} google-prompt-guard -n {{< reuse "agw-docs/snippets/namespace.md" >}}
320+
```
321+
322+
If you set up a local cluster (kind), also delete the credentials secret. For a GKE cluster that uses workload identity, no secret is created.
323+
324+
```sh
325+
kubectl delete secret gcp-credentials -n {{< reuse "agw-docs/snippets/namespace.md" >}}
326+
```

content/docs/kubernetes/main/llm/guardrails/moderation.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ The OpenAI Moderation API detects potentially harmful content across categories
4040
EOF
4141
```
4242

43+
The `policies` field supports more than the `secretRef` authentication shown here. You can choose a different authentication method or tune the connection that agentgateway opens to the Moderation API, such as setting a request timeout or custom TLS. For all the options, see [Backend connection and authentication policies](#backend-connection-and-authentication-policies).
44+
4345
2. Test with content that triggers moderation.
4446
{{< tabs >}}
4547

@@ -83,6 +85,46 @@ The OpenAI Moderation API detects potentially harmful content across categories
8385
Content blocked by moderation policy
8486
```
8587

88+
## Backend connection and authentication policies
89+
90+
The `policies` field configures how agentgateway connects and authenticates to the OpenAI Moderation API when it evaluates a request.
91+
92+
### Authentication
93+
94+
Under `policies.auth`, set one credential source (`secretRef` or `key`). Optionally, set `location` to control where the credential is placed.
95+
96+
| Method | Description |
97+
| -- | -- |
98+
| `secretRef` | Read the API key from a Kubernetes secret. By default, the key that matches the credential location is used, such as `Authorization` for the default header location. To use a different key, set `secretRef.key`. |
99+
| `key` | Send an inline API key in the `Authorization` header. This option is the least secure. Use a secret instead when possible. |
100+
| `location` | Where to place the credential. Defaults to the `Authorization` header with a `Bearer` prefix. To change it, set a `header`, `queryParameter`, or `cookie`. |
101+
102+
### Backend connection settings
103+
104+
You can also tune the connection that agentgateway opens to the OpenAI Moderation backend by setting the following `BackendConnectionPolicy` fields under `policies`.
105+
106+
| Setting | Description |
107+
| -- | -- |
108+
| `tls` | TLS settings for the connection, such as a custom CA certificate or SNI. |
109+
| `http` | HTTP settings, such as the `requestTimeout` and HTTP protocol `version`. |
110+
| `tcp` | TCP connection settings. |
111+
| `tunnel` | Tunnel settings, such as an `HTTPS_PROXY`, used to reach the backend. |
112+
113+
For example, the following prompt guard authenticates with a secret and sets a request timeout for the calls to the Moderation API.
114+
115+
```yaml
116+
- openAIModeration:
117+
model: omni-moderation-latest
118+
policies:
119+
auth:
120+
secretRef:
121+
name: openai-secret
122+
http:
123+
requestTimeout: 5s
124+
```
125+
126+
For the full set of fields, see the [API reference]({{< link-hextra path="/reference/api/" >}}).
127+
86128
## Cleanup
87129
88130
{{< reuse "agw-docs/snippets/cleanup.md" >}}

0 commit comments

Comments
 (0)