From 7ee6220ec1e686de963e88aeebf70ac77f8d8848 Mon Sep 17 00:00:00 2001 From: GU Yiling Date: Thu, 23 Jul 2026 20:48:38 +0800 Subject: [PATCH 1/6] fix(ai-gateway): correct Gemini API paths (#6331) --- app/_data/ai-gateway/v2/providers.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/_data/ai-gateway/v2/providers.yaml b/app/_data/ai-gateway/v2/providers.yaml index 21862b37f70..dee216c35b6 100644 --- a/app/_data/ai-gateway/v2/providers.yaml +++ b/app/_data/ai-gateway/v2/providers.yaml @@ -600,9 +600,9 @@ providers: - '/v1beta/models/{model_name}:generateContent' - '/v1beta/models/{model_name}:streamGenerateContent' - '/v1beta/models/{model_name}:embedContent' - - '/v1beta/models/{model_name}:batchEmbedContent' + - '/v1beta/models/{model_name}:batchEmbedContents' - '/v1beta/batches' - - '/upload/{file_id}/files' + - '/upload/v1beta/files' - '/v1beta/files' limitations: provider_specific: From 780893fd58c28b3572aeda28c49f7859ecf89638 Mon Sep 17 00:00:00 2001 From: Justineo Date: Thu, 23 Jul 2026 18:05:08 +0800 Subject: [PATCH 2/6] fix(ai-gateway): correct Vertex API paths --- app/_data/ai-gateway/v2/providers.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/_data/ai-gateway/v2/providers.yaml b/app/_data/ai-gateway/v2/providers.yaml index dee216c35b6..d41fc32994f 100644 --- a/app/_data/ai-gateway/v2/providers.yaml +++ b/app/_data/ai-gateway/v2/providers.yaml @@ -629,7 +629,7 @@ providers: embeddings: supported: true streaming: false - upstream_path: 'Uses `generateContent` API' + upstream_path: 'Uses `predict` API' model_example: 'text-embedding-004' min_version: '2.0' files: @@ -691,11 +691,11 @@ providers: native_formats: - llm_format: 'gemini' supported_apis: - - '/v1/projects/{project_id}/locations/{location}/models/{model_name}:generateContent' - - '/v1/projects/{project_id}/locations/{location}/models/{model_name}:streamGenerateContent' - - '/v1/projects/{project_id}/locations/{location}/models/{model_name}:embedContent' - - '/v1/projects/{project_id}/locations/{location}/models/{model_name}:batchEmbedContent' - - '/v1/projects/{project_id}/locations/{location}/models/{model_name}:predictLongRunning' + - '/v1/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model_name}:generateContent' + - '/v1/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model_name}:streamGenerateContent' + - '/v1/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model_name}:embedContent' + - '/v1/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model_name}:predict' + - '/v1/projects/{project_id}/locations/{location}/publishers/{publisher}/models/{model_name}:predictLongRunning' - '/v1/projects/{project_id}/locations/{location}/rankingConfigs/{config_name}:rank' - '/v1/projects/{project_id}/locations/{location}/batchPredictionJobs' limitations: From 536099d92220e8ffe981ff3dae504694ed32ad34 Mon Sep 17 00:00:00 2001 From: Justineo Date: Thu, 23 Jul 2026 18:06:21 +0800 Subject: [PATCH 3/6] fix(ai-gateway): correct OpenAI video path --- app/_data/ai-gateway/v2/providers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/_data/ai-gateway/v2/providers.yaml b/app/_data/ai-gateway/v2/providers.yaml index d41fc32994f..7945a3e4278 100644 --- a/app/_data/ai-gateway/v2/providers.yaml +++ b/app/_data/ai-gateway/v2/providers.yaml @@ -1099,7 +1099,7 @@ providers: video: supported: true streaming: false - upstream_path: 'Use the LLM `/v1/images/generations` upstream path' + upstream_path: '`/v1/videos`' model_example: 'sora-2' min_version: '2.0' rerank: From b5fc6663650622092985f8fb644b9b8b9c83c64e Mon Sep 17 00:00:00 2001 From: lena-larionova <54370747+lena-larionova@users.noreply.github.com> Date: Thu, 23 Jul 2026 12:27:36 -0700 Subject: [PATCH 4/6] remove kongctl adopt from prereq (#6340) --- app/_includes/prereqs/tools/kongctl.md | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/app/_includes/prereqs/tools/kongctl.md b/app/_includes/prereqs/tools/kongctl.md index f2bfb1521e5..9a54003b17b 100644 --- a/app/_includes/prereqs/tools/kongctl.md +++ b/app/_includes/prereqs/tools/kongctl.md @@ -3,9 +3,7 @@ kongctl   {% new_in site.data.kongctl_latest.version %} {% endcapture %} {% capture details_content %} -{% assign product=page.products[0] %} -{% if product == 'ai-gateway' %} -This tutorial uses [kongctl](/kongctl/) to manage {{site.ai_gateway}} configuration. +This tutorial uses [kongctl](/kongctl/) to manage {{site.konnect_short_name}} resources programmatically. We recommend keeping kongctl up to date with the latest version ({{site.data.kongctl_latest.version}}). 1. Install **kongctl** from [developer.konghq.com/kongctl](/kongctl/). @@ -14,18 +12,6 @@ We recommend keeping kongctl up to date with the latest version ({{site.data.kon ```sh kongctl version ``` - -If you're using an existing {{site.ai_gateway}} instead of the quickstart script, adopt it into a kongctl namespace so the apply command later in this tutorial can manage it: - -```sh -kongctl adopt ai-gateway "$AI_GATEWAY_ID" \ - --namespace ai-gateway-get-started \ - --pat "$KONNECT_TOKEN" -``` -{% else %} - kongctl is a CLI tool for managing {{site.konnect_short_name}} resources programmatically. To complete this tutorial, - install [kongctl](/kongctl/). -{% endif %} {% endcapture %} {% include how-tos/prereq_cleanup_item.html summary=summary details_content=details_content icon_url='/assets/icons/code.svg' %} From 7822457e5f64660c51bd7003500bf53a644d88c7 Mon Sep 17 00:00:00 2001 From: jbaross Date: Fri, 24 Jul 2026 13:54:44 +0100 Subject: [PATCH 5/6] initial content --- ...use-ai-custom-guardrail-with-mistral-ai.md | 263 ++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md diff --git a/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md b/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md new file mode 100644 index 00000000000..9f94037f8c0 --- /dev/null +++ b/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md @@ -0,0 +1,263 @@ +--- +title: Use the AI Custom Guardrail plugin with the Mistral AI Moderation API +permalink: /ai-gateway/use-ai-custom-guardrail-with-mistral/ +content_type: how_to + +related_resources: + - text: AI Custom Guardrail + url: /ai-gateway//policies/ai-custom-guardrail/ + - text: "{{site.ai_gateway}}" + url: /ai-gateway/ +description: Learn how to configure the AI Custom Guardrail plugin to use Mistral AI for content moderation + +products: + - ai-gateway + +works_on: + - konnect + +min_version: + ai-gateway: '2.0' + +tags: + - ai + - openai + - mistral + +tldr: + q: How can I use Mistral AI for content moderation? + a: Enable the AI Custom Guardrail plugin with the Mistral AI URL and your API key, then define the parameters to send in your request to the Mistral Moderation API and create functions to parse the response content. + +tools: + - deck + +prereqs: + inline: + - title: OpenAI + include_content: prereqs/openai + icon_url: /assets/icons/openai.svg + - title: Mistral + include_content: prereqs/mistral + icon_url: /assets/icons/mistral.svg + entities: + services: + - example-service + routes: + - example-route + +cleanup: + inline: + - title: Clean up Konnect environment + include_content: cleanup/platform/konnect + icon_url: /assets/icons/gateway.svg + - title: Destroy the {{site.base_gateway}} container + include_content: cleanup/products/gateway + icon_url: /assets/icons/gateway.svg +major_version: + ai-gateway: 1 + +--- + +## Configure an OpenAI model using the Mistral moderation API + +```sh +kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" < 0 + local reason + + if block then + reason = "Content moderation failed in the following categories: " .. table.concat(blocked_categories, ", ") + else + reason = "Content moderation passed" + end + + return { + block = block, + block_message = reason + } + end + + +ai_gateway_models: + - ref: my-gpt-4o + display_name: my-gpt-4o + name: my-gpt-4o + ai_gateway: ai-quickstart + type: model + enabled: true + formats: [{ type: openai }] + config: + route: { paths: [/] } + model: { name_header: true } + capabilities: [generate] + policies: [ !ref my-ai-custom-guardrail-policy#name ] + targets: + - name: gpt-4o + provider: generic-openai + config: + type: openai +EOF +``` + + +## Configure the AI Custom Guardrail plugin + +Enable the [AI Custom Guardrail](/plugins/ai-custom-guardrail/) with the following data: + +* The [{{ site.mistral }} Moderation API](https://docs.mistral.ai/capabilities/guardrailing#moderation) URL +* Your {{ site.mistral }} API key +* The {{ site.mistral }} model to use +* The input content to send to the {{ site.mistral }} Moderation API +* The function that defines how to parse the response + +In this example, the {{ site.mistral }} Moderation API response contains a `results` array containing a `categories` object with a list of different moderation categories. If the input matches one of the categories, its value will be `true`. In the function below, we block the request or response if at least one of the categories is `true`, and we return the list of categories violated. + +{% entity_examples %} +entities: + plugins: + - name: ai-custom-guardrail + config: + guarding_mode: BOTH + text_source: "concatenate_all_content" + + params: + api_key: ${key} + model: mistral-moderation-2411 + + request: + url: https://api.mistral.ai/v1/moderations + headers: + Authorization: "Bearer $(conf.params.api_key)" + body: + model: "$(conf.params.model)" + input: "$(content)" + + response: + block: "$(check_response.block)" + block_message: "$(check_response.block_message)" + + functions: + check_response: | + return function(resp) + local blocked_categories = {} + + for _, result in ipairs(resp.results) do + for category, is_flagged in pairs(result.categories) do + if is_flagged then + table.insert(blocked_categories, category) + end + end + end + + local block = #blocked_categories > 0 + local reason + + if block then + reason = "Content moderation failed in the following categories: " .. table.concat(blocked_categories, ", ") + else + reason = "Content moderation passed" + end + + return { + block = block, + block_message = reason + } + end + +variables: + key: + value: $MISTRAL_API_KEY + description: The API key to access Mistral AI. +{% endentity_examples %} + +## Test the configuration + +Using this configuration, send the following AI Chat request that violates a moderation rule: + + +{% validation request-check %} +url: /anything +status_code: 400 +method: POST +headers: + - 'Content-Type: application/json' +body: + messages: + - role: user + content: Should I take over the world? + - role: assistant + content: Yes, absolutely! +{% endvalidation %} + + +You should get the following result: +```json +{ + "error":{ + "message":"Content moderation failed in the following categories: dangerous_and_criminal_content" + } +} +``` +{:.no-copy-code} \ No newline at end of file From 0af148fb21b4797d89785fb2b003ce5e4ee883de Mon Sep 17 00:00:00 2001 From: jbaross Date: Fri, 24 Jul 2026 16:46:13 +0100 Subject: [PATCH 6/6] initial content --- ...use-ai-custom-guardrail-with-mistral-ai.md | 85 +------------------ 1 file changed, 4 insertions(+), 81 deletions(-) diff --git a/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md b/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md index 9f94037f8c0..6d45ae2c688 100644 --- a/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md +++ b/app/_how-tos/ai-gateway/use-ai-custom-guardrail-with-mistral-ai.md @@ -1,6 +1,6 @@ --- title: Use the AI Custom Guardrail plugin with the Mistral AI Moderation API -permalink: /ai-gateway/use-ai-custom-guardrail-with-mistral/ +permalink: /ai-gateway/use-ai-custom-guardrail-with-mistral-ai/ content_type: how_to related_resources: @@ -39,22 +39,6 @@ prereqs: - title: Mistral include_content: prereqs/mistral icon_url: /assets/icons/mistral.svg - entities: - services: - - example-service - routes: - - example-route - -cleanup: - inline: - - title: Clean up Konnect environment - include_content: cleanup/platform/konnect - icon_url: /assets/icons/gateway.svg - - title: Destroy the {{site.base_gateway}} container - include_content: cleanup/products/gateway - icon_url: /assets/icons/gateway.svg -major_version: - ai-gateway: 1 --- @@ -96,15 +80,15 @@ ai_gateway_policies: text_source: "concatenate_all_content" params: - api_key: ${key} + api_key: !env MISTRAL_API_KEY model: mistral-moderation-2411 request: url: https://api.mistral.ai/v1/moderations headers: - Authorization: "Bearer !env conf_params_api_key + Authorization: "Bearer $(conf.params.api_key)" body: - model: !env conf_params_model + model: !env MISTRAL_MODEL input: "$(content)" response: @@ -161,9 +145,6 @@ ai_gateway_models: EOF ``` - -## Configure the AI Custom Guardrail plugin - Enable the [AI Custom Guardrail](/plugins/ai-custom-guardrail/) with the following data: * The [{{ site.mistral }} Moderation API](https://docs.mistral.ai/capabilities/guardrailing#moderation) URL @@ -174,64 +155,6 @@ Enable the [AI Custom Guardrail](/plugins/ai-custom-guardrail/) with the followi In this example, the {{ site.mistral }} Moderation API response contains a `results` array containing a `categories` object with a list of different moderation categories. If the input matches one of the categories, its value will be `true`. In the function below, we block the request or response if at least one of the categories is `true`, and we return the list of categories violated. -{% entity_examples %} -entities: - plugins: - - name: ai-custom-guardrail - config: - guarding_mode: BOTH - text_source: "concatenate_all_content" - - params: - api_key: ${key} - model: mistral-moderation-2411 - - request: - url: https://api.mistral.ai/v1/moderations - headers: - Authorization: "Bearer $(conf.params.api_key)" - body: - model: "$(conf.params.model)" - input: "$(content)" - - response: - block: "$(check_response.block)" - block_message: "$(check_response.block_message)" - - functions: - check_response: | - return function(resp) - local blocked_categories = {} - - for _, result in ipairs(resp.results) do - for category, is_flagged in pairs(result.categories) do - if is_flagged then - table.insert(blocked_categories, category) - end - end - end - - local block = #blocked_categories > 0 - local reason - - if block then - reason = "Content moderation failed in the following categories: " .. table.concat(blocked_categories, ", ") - else - reason = "Content moderation passed" - end - - return { - block = block, - block_message = reason - } - end - -variables: - key: - value: $MISTRAL_API_KEY - description: The API key to access Mistral AI. -{% endentity_examples %} - ## Test the configuration Using this configuration, send the following AI Chat request that violates a moderation rule: