---
title: "Create a AiResponseTransformer plugin"
method: POST
path: "/{workspace}/plugins#AiResponseTransformer"
tags: ["Plugins"]
---

# Create a AiResponseTransformer plugin

`POST /{workspace}/plugins#AiResponseTransformer`

Create a AiResponseTransformer plugin

## Request body

- AiResponseTransformerPlugin — A Plugin entity represents a plugin configuration that will be executed during the HTTP request/response lifecycle. It is how you can add functionalities to Services that run behind Kong, like Authentication or Rate Limiting for example. You can find more information about how to install and what values each plugin takes by visiting the [Kong Hub](https://docs.konghq.com/hub/). When adding a Plugin Configuration to a Service, every request made by a client to that Service will run said Plugin. If a Plugin needs to be tuned to different values for some specific Consumers, you can do so by creating a separate plugin instance that specifies both the Service and the Consumer, through the `service` and `consumer` fields.
  - `condition` string, nullable — An expression used for conditional control over plugin execution. If the expression evaluates to `true` during the request flow, the plugin is executed; otherwise, it is skipped.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `instance_name` string, nullable — A unique string representing a UTF-8 encoded name.
  - `name` 'ai-response-transformer', required — The name of the Plugin that's going to be added. Currently, the Plugin must be installed in every Kong instance separately.
  - `ordering` object, nullable
    - `after` object
      - `access` string[]
    - `before` object
      - `access` string[]
  - `partials` object[] — A list of partials to be used by the plugin.
    - `id` string — A string representing a UUID (universally unique identifier).
    - `name` string — A unique string representing a UTF-8 encoded name.
    - `path` string
  - `tags` string[], nullable — An optional set of strings associated with the Plugin for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `config` object, required
    - `http_proxy_host` string — A string representing a host name, such as example.com.
    - `http_proxy_port` integer — An integer representing a port number between 0 and 65535, inclusive.
    - `http_timeout` integer — Timeout in milliseconds for the AI upstream service.
    - `https_proxy_host` string — A string representing a host name, such as example.com.
    - `https_proxy_port` integer — An integer representing a port number between 0 and 65535, inclusive.
    - `https_verify` boolean — Verify the TLS certificate of the AI upstream service.
    - `llm` object, required
      - `auth` object
        - `allow_override` boolean — If enabled, the authorization header or parameter can be overridden in the request by the value configured in the plugin.
        - `aws_access_key_id` string — Set this if you are using an AWS provider (Bedrock) and you are authenticating using static IAM User credentials. Setting this will override the AWS_ACCESS_KEY_ID environment variable for this plugin instance.
        - `aws_secret_access_key` string — Set this if you are using an AWS provider (Bedrock) and you are authenticating using static IAM User credentials. Setting this will override the AWS_SECRET_ACCESS_KEY environment variable for this plugin instance.
        - `azure_client_id` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the client ID.
        - `azure_client_secret` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the client secret.
        - `azure_tenant_id` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the tenant ID.
        - `azure_use_managed_identity` boolean — Set true to use the Azure Cloud Managed Identity (or user-assigned identity) to authenticate with Azure-provider models.
        - `gcp_metadata_url` string — Custom metadata URL for GCP authentication. Useful for restricted network environments or custom GCP endpoints. If null, Kong will use the default Google metadata endpoint.
        - `gcp_oauth_token_url` string — Custom OAuth token URL for GCP authentication. Useful for restricted network environments or custom GCP endpoints. If null, Kong will use the default Google OAuth token endpoint.
        - `gcp_service_account_json` string — Set this field to the full JSON of the GCP service account to authenticate, if required. If null (and gcp_use_service_account is true), Kong will attempt to read from environment variable `GCP_SERVICE_ACCOUNT`.
        - `gcp_use_service_account` boolean — Use service account auth for GCP-based providers and models.
        - `header_name` string — If AI model requires authentication via Authorization or API key header, specify its name here.
        - `header_value` string — Specify the full auth header value for 'header_name', for example 'Bearer key' or just 'key'.
        - `param_location` 'body' | 'query' — Specify whether the 'param_name' and 'param_value' options go in a query string, or the POST form/JSON body.
        - `param_name` string — If AI model requires authentication via query parameter, specify its name here.
        - `param_value` string — Specify the full parameter value for 'param_name'.
      - `description` string — The semantic description of the target, required if using semantic load balancing. Specially, setting this to 'CATCHALL' will indicate such target to be used when no other targets match the semantic threshold. Only used by ai-proxy-advanced.
      - `logging` object
        - `log_payloads` boolean — If enabled, will log the request and response body into the Kong log plugin(s) output.Furthermore if Opentelemetry instrumentation is enabled the traces will contain this data as well.
        - `log_statistics` boolean — If enabled and supported by the driver, will add model usage and token metrics into the Kong log plugin(s) output.
      - `metadata` object, nullable — For internal use only.
      - `model` object, required
        - `model_alias` string — The model name parameter from the request that this model should map to.
        - `name` string — Model name to execute.
        - `options` object — Key/value settings for the model
          - `anthropic_version` string — Defines the schema/API version, if using Anthropic provider.
          - `azure_api_version` string — 'api-version' for Azure OpenAI instances.
          - `azure_deployment_id` string — Deployment ID for Azure OpenAI instances.
          - `azure_instance` string — Instance name for Azure OpenAI hosted models.
          - `bedrock` object
            - `aws_assume_role_arn` string — If using AWS providers (Bedrock) you can assume a different role after authentication with the current IAM context is successful.
            - `aws_region` string — If using AWS providers (Bedrock) you can override the `AWS_REGION` environment variable by setting this option.
            - `aws_role_session_name` string — If using AWS providers (Bedrock), set the identifier of the assumed role session.
            - `aws_sts_endpoint_url` string — If using AWS providers (Bedrock), override the STS endpoint URL when assuming a different role.
            - `batch_bucket_prefix` string — S3 URI prefix (s3://bucket/prefix/) where Bedrock will get input files from and store results to for native batch API.
            - `batch_role_arn` string — AWS role arn used for calling batch API. Try to get the value from request if ommited.
            - `embeddings_normalize` boolean — If using AWS providers (Bedrock), set to true to normalize the embeddings.
            - `performance_config_latency` string — Force the client's performance configuration 'latency' for all requests. Leave empty to let the consumer select the performance configuration.
            - `video_output_s3_uri` string — S3 URI (s3://bucket/prefix) where Bedrock will store generated video files. Required for video generation.
          - `cohere` object
            - `embedding_input_type` 'classification' | 'clustering' | 'image' | 'search_document' | 'search_query' — The purpose of the input text to calculate embedding vectors.
            - `wait_for_model` boolean — Wait for the model if it is not ready
          - `dashscope` object
            - `international` boolean — Two Dashscope endpoints are available, and the international endpoint will be used when this is set to `true`. It is recommended to set this to `true` when using international version of dashscope.
          - `databricks` object
            - `workspace_instance_id` string — Workspace Instance ID ('dbc-xxx-yyy') for Databricks model serving.
          - `embeddings_dimensions` integer — If using embeddings models, set the number of dimensions to generate.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `endpoint_id` string — If running Gemini on Vertex Model Garden, specify the endpoint ID.
            - `location_id` string — If running Gemini on Vertex, specify the location ID.
            - `project_id` string — If running Gemini on Vertex, specify the project ID.
          - `huggingface` object
            - `use_cache` boolean — Use the cache layer on the inference API
            - `wait_for_model` boolean — Wait for the model if it is not ready
          - `input_cost` number — Defines the cost per 1M tokens in your prompt.
          - `llama2_format` 'ollama' | 'openai' | 'raw' — If using llama2 provider, select the upstream message format.
          - `max_tokens` integer — Defines the max_tokens, if using chat or completion models.
          - `mistral_format` 'ollama' | 'openai' — If using mistral provider, select the upstream message format.
          - `output_cost` number — Defines the cost per 1M tokens in the output of the AI.
          - `temperature` number — Defines the matching temperature, if using chat or completion models.
          - `top_k` integer — Defines the top-k most likely tokens, if supported.
          - `top_p` number — Defines the top-p probability mass, if supported.
          - `upstream_path` string — Manually specify or override the AI operation path, used when e.g. using the 'preserve' route_type.
          - `upstream_url` string — Manually specify or override the full URL to the AI operation endpoints, when calling (self-)hosted models, or for running via a private endpoint.
        - `provider` 'anthropic' | 'azure' | 'bedrock' | 'cerebras' | 'cohere' | 'dashscope' | 'databricks' | 'deepseek' | 'gemini' | 'huggingface' | 'llama2' | 'mistral' | 'ollama' | 'openai' | 'vllm' | 'xai', required — AI provider request format - Kong translates requests to and from the specified backend compatible formats.
      - `route_type` 'audio/v1/audio/speech' | 'audio/v1/audio/transcriptions' | 'audio/v1/audio/translations' | 'image/v1/images/edits' | 'image/v1/images/generations' | 'llm/v1/assistants' | 'llm/v1/batches' | 'llm/v1/chat' | 'llm/v1/completions' | 'llm/v1/embeddings' | 'llm/v1/files' | 'llm/v1/responses' | 'preserve' | 'realtime/v1/realtime' | 'video/v1/videos/generations', required — The model's operation implementation, for this provider.
      - `weight` integer — The weight this target gets within the upstream loadbalancer (1-65535). Only used by ai-proxy-advanced.
    - `max_request_body_size` integer — max allowed body size allowed to be introspected. 0 means unlimited, but the size of this body will still be limited by Nginx's client_max_body_size.
    - `parse_llm_response_json_instructions` boolean — Set true to read specific response format from the LLM, and accordingly set the status code / body / headers that proxy back to the client. You need to engineer your LLM prompt to return the correct format, see plugin docs 'Overview' page for usage instructions.
    - `prompt` string, required — Use this prompt to tune the LLM system/assistant message for the returning proxy response (from the upstream), adn what response format you are expecting.
    - `transformation_extract_pattern` string — Defines the regular expression that must match to indicate a successful AI transformation at the response phase. The first match will be set as the returning body. If the AI service's response doesn't match this pattern, a failure is returned to the client.
  - `consumer` object — If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer.
    - `id` string
  - `consumer_group` object — If set, the plugin will activate only for requests where the specified consumer group has been authenticated. (Note that some plugins can not be restricted to consumers groups this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer Groups
    - `id` string
  - `protocols` string[] — A set of strings representing HTTP protocols.
  - `route` object — If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.
    - `id` string
  - `service` object — If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.
    - `id` string

## Response `201`

Created AiResponseTransformer plugin

- AiResponseTransformerPlugin — A Plugin entity represents a plugin configuration that will be executed during the HTTP request/response lifecycle. It is how you can add functionalities to Services that run behind Kong, like Authentication or Rate Limiting for example. You can find more information about how to install and what values each plugin takes by visiting the [Kong Hub](https://docs.konghq.com/hub/). When adding a Plugin Configuration to a Service, every request made by a client to that Service will run said Plugin. If a Plugin needs to be tuned to different values for some specific Consumers, you can do so by creating a separate plugin instance that specifies both the Service and the Consumer, through the `service` and `consumer` fields.
  - `condition` string, nullable — An expression used for conditional control over plugin execution. If the expression evaluates to `true` during the request flow, the plugin is executed; otherwise, it is skipped.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `instance_name` string, nullable — A unique string representing a UTF-8 encoded name.
  - `name` 'ai-response-transformer', required — The name of the Plugin that's going to be added. Currently, the Plugin must be installed in every Kong instance separately.
  - `ordering` object, nullable
    - `after` object
      - `access` string[]
    - `before` object
      - `access` string[]
  - `partials` object[] — A list of partials to be used by the plugin.
    - `id` string — A string representing a UUID (universally unique identifier).
    - `name` string — A unique string representing a UTF-8 encoded name.
    - `path` string
  - `tags` string[], nullable — An optional set of strings associated with the Plugin for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `config` object, required
    - `http_proxy_host` string — A string representing a host name, such as example.com.
    - `http_proxy_port` integer — An integer representing a port number between 0 and 65535, inclusive.
    - `http_timeout` integer — Timeout in milliseconds for the AI upstream service.
    - `https_proxy_host` string — A string representing a host name, such as example.com.
    - `https_proxy_port` integer — An integer representing a port number between 0 and 65535, inclusive.
    - `https_verify` boolean — Verify the TLS certificate of the AI upstream service.
    - `llm` object, required
      - `auth` object
        - `allow_override` boolean — If enabled, the authorization header or parameter can be overridden in the request by the value configured in the plugin.
        - `aws_access_key_id` string — Set this if you are using an AWS provider (Bedrock) and you are authenticating using static IAM User credentials. Setting this will override the AWS_ACCESS_KEY_ID environment variable for this plugin instance.
        - `aws_secret_access_key` string — Set this if you are using an AWS provider (Bedrock) and you are authenticating using static IAM User credentials. Setting this will override the AWS_SECRET_ACCESS_KEY environment variable for this plugin instance.
        - `azure_client_id` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the client ID.
        - `azure_client_secret` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the client secret.
        - `azure_tenant_id` string — If azure_use_managed_identity is set to true, and you need to use a different user-assigned identity for this LLM instance, set the tenant ID.
        - `azure_use_managed_identity` boolean — Set true to use the Azure Cloud Managed Identity (or user-assigned identity) to authenticate with Azure-provider models.
        - `gcp_metadata_url` string — Custom metadata URL for GCP authentication. Useful for restricted network environments or custom GCP endpoints. If null, Kong will use the default Google metadata endpoint.
        - `gcp_oauth_token_url` string — Custom OAuth token URL for GCP authentication. Useful for restricted network environments or custom GCP endpoints. If null, Kong will use the default Google OAuth token endpoint.
        - `gcp_service_account_json` string — Set this field to the full JSON of the GCP service account to authenticate, if required. If null (and gcp_use_service_account is true), Kong will attempt to read from environment variable `GCP_SERVICE_ACCOUNT`.
        - `gcp_use_service_account` boolean — Use service account auth for GCP-based providers and models.
        - `header_name` string — If AI model requires authentication via Authorization or API key header, specify its name here.
        - `header_value` string — Specify the full auth header value for 'header_name', for example 'Bearer key' or just 'key'.
        - `param_location` 'body' | 'query' — Specify whether the 'param_name' and 'param_value' options go in a query string, or the POST form/JSON body.
        - `param_name` string — If AI model requires authentication via query parameter, specify its name here.
        - `param_value` string — Specify the full parameter value for 'param_name'.
      - `description` string — The semantic description of the target, required if using semantic load balancing. Specially, setting this to 'CATCHALL' will indicate such target to be used when no other targets match the semantic threshold. Only used by ai-proxy-advanced.
      - `logging` object
        - `log_payloads` boolean — If enabled, will log the request and response body into the Kong log plugin(s) output.Furthermore if Opentelemetry instrumentation is enabled the traces will contain this data as well.
        - `log_statistics` boolean — If enabled and supported by the driver, will add model usage and token metrics into the Kong log plugin(s) output.
      - `metadata` object, nullable — For internal use only.
      - `model` object, required
        - `model_alias` string — The model name parameter from the request that this model should map to.
        - `name` string — Model name to execute.
        - `options` object — Key/value settings for the model
          - `anthropic_version` string — Defines the schema/API version, if using Anthropic provider.
          - `azure_api_version` string — 'api-version' for Azure OpenAI instances.
          - `azure_deployment_id` string — Deployment ID for Azure OpenAI instances.
          - `azure_instance` string — Instance name for Azure OpenAI hosted models.
          - `bedrock` object
            - `aws_assume_role_arn` string — If using AWS providers (Bedrock) you can assume a different role after authentication with the current IAM context is successful.
            - `aws_region` string — If using AWS providers (Bedrock) you can override the `AWS_REGION` environment variable by setting this option.
            - `aws_role_session_name` string — If using AWS providers (Bedrock), set the identifier of the assumed role session.
            - `aws_sts_endpoint_url` string — If using AWS providers (Bedrock), override the STS endpoint URL when assuming a different role.
            - `batch_bucket_prefix` string — S3 URI prefix (s3://bucket/prefix/) where Bedrock will get input files from and store results to for native batch API.
            - `batch_role_arn` string — AWS role arn used for calling batch API. Try to get the value from request if ommited.
            - `embeddings_normalize` boolean — If using AWS providers (Bedrock), set to true to normalize the embeddings.
            - `performance_config_latency` string — Force the client's performance configuration 'latency' for all requests. Leave empty to let the consumer select the performance configuration.
            - `video_output_s3_uri` string — S3 URI (s3://bucket/prefix) where Bedrock will store generated video files. Required for video generation.
          - `cohere` object
            - `embedding_input_type` 'classification' | 'clustering' | 'image' | 'search_document' | 'search_query' — The purpose of the input text to calculate embedding vectors.
            - `wait_for_model` boolean — Wait for the model if it is not ready
          - `dashscope` object
            - `international` boolean — Two Dashscope endpoints are available, and the international endpoint will be used when this is set to `true`. It is recommended to set this to `true` when using international version of dashscope.
          - `databricks` object
            - `workspace_instance_id` string — Workspace Instance ID ('dbc-xxx-yyy') for Databricks model serving.
          - `embeddings_dimensions` integer — If using embeddings models, set the number of dimensions to generate.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `endpoint_id` string — If running Gemini on Vertex Model Garden, specify the endpoint ID.
            - `location_id` string — If running Gemini on Vertex, specify the location ID.
            - `project_id` string — If running Gemini on Vertex, specify the project ID.
          - `huggingface` object
            - `use_cache` boolean — Use the cache layer on the inference API
            - `wait_for_model` boolean — Wait for the model if it is not ready
          - `input_cost` number — Defines the cost per 1M tokens in your prompt.
          - `llama2_format` 'ollama' | 'openai' | 'raw' — If using llama2 provider, select the upstream message format.
          - `max_tokens` integer — Defines the max_tokens, if using chat or completion models.
          - `mistral_format` 'ollama' | 'openai' — If using mistral provider, select the upstream message format.
          - `output_cost` number — Defines the cost per 1M tokens in the output of the AI.
          - `temperature` number — Defines the matching temperature, if using chat or completion models.
          - `top_k` integer — Defines the top-k most likely tokens, if supported.
          - `top_p` number — Defines the top-p probability mass, if supported.
          - `upstream_path` string — Manually specify or override the AI operation path, used when e.g. using the 'preserve' route_type.
          - `upstream_url` string — Manually specify or override the full URL to the AI operation endpoints, when calling (self-)hosted models, or for running via a private endpoint.
        - `provider` 'anthropic' | 'azure' | 'bedrock' | 'cerebras' | 'cohere' | 'dashscope' | 'databricks' | 'deepseek' | 'gemini' | 'huggingface' | 'llama2' | 'mistral' | 'ollama' | 'openai' | 'vllm' | 'xai', required — AI provider request format - Kong translates requests to and from the specified backend compatible formats.
      - `route_type` 'audio/v1/audio/speech' | 'audio/v1/audio/transcriptions' | 'audio/v1/audio/translations' | 'image/v1/images/edits' | 'image/v1/images/generations' | 'llm/v1/assistants' | 'llm/v1/batches' | 'llm/v1/chat' | 'llm/v1/completions' | 'llm/v1/embeddings' | 'llm/v1/files' | 'llm/v1/responses' | 'preserve' | 'realtime/v1/realtime' | 'video/v1/videos/generations', required — The model's operation implementation, for this provider.
      - `weight` integer — The weight this target gets within the upstream loadbalancer (1-65535). Only used by ai-proxy-advanced.
    - `max_request_body_size` integer — max allowed body size allowed to be introspected. 0 means unlimited, but the size of this body will still be limited by Nginx's client_max_body_size.
    - `parse_llm_response_json_instructions` boolean — Set true to read specific response format from the LLM, and accordingly set the status code / body / headers that proxy back to the client. You need to engineer your LLM prompt to return the correct format, see plugin docs 'Overview' page for usage instructions.
    - `prompt` string, required — Use this prompt to tune the LLM system/assistant message for the returning proxy response (from the upstream), adn what response format you are expecting.
    - `transformation_extract_pattern` string — Defines the regular expression that must match to indicate a successful AI transformation at the response phase. The first match will be set as the returning body. If the AI service's response doesn't match this pattern, a failure is returned to the client.
  - `consumer` object — If set, the plugin will activate only for requests where the specified has been authenticated. (Note that some plugins can not be restricted to consumers this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer.
    - `id` string
  - `consumer_group` object — If set, the plugin will activate only for requests where the specified consumer group has been authenticated. (Note that some plugins can not be restricted to consumers groups this way.). Leave unset for the plugin to activate regardless of the authenticated Consumer Groups
    - `id` string
  - `protocols` string[] — A set of strings representing HTTP protocols.
  - `route` object — If set, the plugin will only activate when receiving requests via the specified route. Leave unset for the plugin to activate regardless of the route being used.
    - `id` string
  - `service` object — If set, the plugin will only activate when receiving requests via one of the routes belonging to the specified Service. Leave unset for the plugin to activate regardless of the Service being matched.
    - `id` string

## Other responses

- `401` — Unauthorized

---

[API](https://skmtc.net/kong/apis/kong-enterprise-admin-api.md) · [All operations](https://skmtc.net/kong/apis/kong-enterprise-admin-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kong/kong-enterprise-admin-api/revisions/28b1f8a59cdc/schema)
