---
title: "Create a AiProxyAdvanced plugin"
method: POST
path: "/plugins#AiProxyAdvanced"
tags: ["Plugins"]
---

# Create a AiProxyAdvanced plugin

`POST /plugins#AiProxyAdvanced`

Create a AiProxyAdvanced plugin

## Request body

- AiProxyAdvancedPlugin — 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.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable
  - `instance_name` string, nullable
  - `name` 'ai-proxy-advanced', 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[], nullable
    - `id` string
    - `name` string
    - `path` string
  - `tags` string[] — 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
    - `balancer` object
      - `algorithm` 'consistent-hashing' | 'lowest-latency' | 'lowest-usage' | 'priority' | 'round-robin' | 'semantic' — Which load balancing algorithm to use.
      - `connect_timeout` integer
      - `failover_criteria` string[] — Specifies in which cases an upstream response should be failover to the next target. Each option in the array is equivalent to the function of http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
      - `hash_on_header` string — The header to use for consistent-hashing.
      - `latency_strategy` 'e2e' | 'tpot' — What metrics to use for latency. Available values are: `tpot` (time-per-output-token) and `e2e`.
      - `read_timeout` integer
      - `retries` integer — The number of retries to execute upon failure to proxy.
      - `slots` integer — The number of slots in the load balancer algorithm.
      - `tokens_count_strategy` 'completion-tokens' | 'cost' | 'prompt-tokens' | 'total-tokens' — What tokens to use for usage calculation. Available values are: `total_tokens` `prompt_tokens`, `completion_tokens` and `cost`.
      - `write_timeout` integer
    - `embeddings` object
      - `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_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'.
      - `model` object, required
        - `name` string, required — Model name to execute.
        - `options` object — Key/value settings for the model
          - `azure` object, required
            - `api_version` string — 'api-version' for Azure OpenAI instances.
            - `deployment_id` string — Deployment ID for Azure OpenAI instances.
            - `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.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `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
          - `upstream_url` string — upstream url for the embeddings
        - `provider` 'azure' | 'bedrock' | 'gemini' | 'huggingface' | 'mistral' | 'openai', required — AI provider format to use for embeddings API
    - `llm_format` 'bedrock' | 'gemini' | 'openai' — LLM input and output format and schema to use
    - `max_request_body_size` integer — max allowed body size allowed to be introspected
    - `model_name_header` boolean — Display the model name selected in the X-Kong-LLM-Model response header
    - `response_streaming` 'allow' | 'always' | 'deny' — Whether to 'optionally allow', 'deny', or 'always' (force) the streaming of answers via server sent events.
    - `targets` object[]
      - `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_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.
      - `logging` object, required
        - `log_payloads` boolean — If enabled, will log the request and response body into the Kong log plugin(s) output.
        - `log_statistics` boolean — If enabled and supported by the driver, will add model usage and token metrics into the Kong log plugin(s) output.
      - `model` object, required
        - `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.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `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' | 'cohere' | 'gemini' | 'huggingface' | 'llama2' | 'mistral' | 'openai', required — AI provider request format - Kong translates requests to and from the specified backend compatible formats.
      - `route_type` 'llm/v1/chat' | 'llm/v1/completions' | 'preserve', required — The model's operation implementation, for this provider. Set to `preserve` to pass through without transformation.
      - `weight` integer — The weight this target gets within the upstream loadbalancer (1-65535).
    - `vectordb` object
      - `dimensions` integer, required — the desired dimensionality for the vectors
      - `distance_metric` 'cosine' | 'euclidean', required — the distance metric to use for vector searches
      - `pgvector` object, required
        - `database` string — the database of the pgvector database
        - `host` string — the host of the pgvector database
        - `password` string — the password of the pgvector database
        - `port` integer — the port of the pgvector database
        - `ssl` boolean — whether to use ssl for the pgvector database
        - `ssl_cert` string — the path of ssl cert to use for the pgvector database
        - `ssl_cert_key` string — the path of ssl cert key to use for the pgvector database
        - `ssl_required` boolean — whether ssl is required for the pgvector database
        - `ssl_verify` boolean — whether to verify ssl for the pgvector database
        - `ssl_version` 'any' | 'tlsv1_2' | 'tlsv1_3' — the ssl version to use for the pgvector database
        - `timeout` number — the timeout of the pgvector database
        - `user` string — the user of the pgvector database
      - `redis` object, required
        - `cluster_max_redirections` integer — Maximum retry attempts for redirection.
        - `cluster_nodes` object[] — Cluster addresses to use for Redis connections when the `redis` strategy is defined. Defining this field implies using a Redis Cluster. The minimum length of the array is 1 element.
          - `ip` string — A string representing a host name, such as example.com.
          - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `connect_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `connection_is_proxied` boolean — If the connection to Redis is proxied (e.g. Envoy), set it `true`. Set the `host` and `port` to point to the proxy address.
        - `database` integer — Database to use for the Redis connection when using the `redis` strategy
        - `host` string — A string representing a host name, such as example.com.
        - `keepalive_backlog` integer — Limits the total number of opened connections for a pool. If the connection pool is full, connection queues above the limit go into the backlog queue. If the backlog queue is full, subsequent connect operations fail and return `nil`. Queued operations (subject to set timeouts) resume once the number of connections in the pool is less than `keepalive_pool_size`. If latency is high or throughput is low, try increasing this value. Empirically, this value is larger than `keepalive_pool_size`.
        - `keepalive_pool_size` integer — The size limit for every cosocket connection pool associated with every remote server, per worker process. If neither `keepalive_pool_size` nor `keepalive_backlog` is specified, no pool is created. If `keepalive_pool_size` isn't specified but `keepalive_backlog` is specified, then the pool uses the default value. Try to increase (e.g. 512) this value if latency is high or throughput is low.
        - `password` string — Password to use for Redis connections. If undefined, no AUTH commands are sent to Redis.
        - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `read_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `send_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `sentinel_master` string — Sentinel master to use for Redis connections. Defining this value implies using Redis Sentinel.
        - `sentinel_nodes` object[] — Sentinel node addresses to use for Redis connections when the `redis` strategy is defined. Defining this field implies using a Redis Sentinel. The minimum length of the array is 1 element.
          - `host` string — A string representing a host name, such as example.com.
          - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `sentinel_password` string — Sentinel password to authenticate with a Redis Sentinel instance. If undefined, no AUTH commands are sent to Redis Sentinels.
        - `sentinel_role` 'any' | 'master' | 'slave' — Sentinel role to use for Redis connections when the `redis` strategy is defined. Defining this value implies using Redis Sentinel.
        - `sentinel_username` string — Sentinel username to authenticate with a Redis Sentinel instance. If undefined, ACL authentication won't be performed. This requires Redis v6.2.0+.
        - `server_name` string — A string representing an SNI (server name indication) value for TLS.
        - `ssl` boolean — If set to true, uses SSL to connect to Redis.
        - `ssl_verify` boolean — If set to true, verifies the validity of the server SSL certificate. If setting this parameter, also configure `lua_ssl_trusted_certificate` in `kong.conf` to specify the CA (or server) certificate used by your Redis server. You may also need to configure `lua_ssl_verify_depth` accordingly.
        - `username` string — Username to use for Redis connections. If undefined, ACL authentication won't be performed. This requires Redis v6.0.0+. To be compatible with Redis v5.x.y, you can set it to `default`.
      - `strategy` 'pgvector' | 'redis', required — which vector database driver to use
      - `threshold` number, required — the default similarity threshold for accepting semantic search results (float)
  - `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 AiProxyAdvanced plugin

- AiProxyAdvancedPlugin — 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.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `enabled` boolean, nullable — Whether the plugin is applied.
  - `id` string, nullable
  - `instance_name` string, nullable
  - `name` 'ai-proxy-advanced', 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[], nullable
    - `id` string
    - `name` string
    - `path` string
  - `tags` string[] — 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
    - `balancer` object
      - `algorithm` 'consistent-hashing' | 'lowest-latency' | 'lowest-usage' | 'priority' | 'round-robin' | 'semantic' — Which load balancing algorithm to use.
      - `connect_timeout` integer
      - `failover_criteria` string[] — Specifies in which cases an upstream response should be failover to the next target. Each option in the array is equivalent to the function of http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
      - `hash_on_header` string — The header to use for consistent-hashing.
      - `latency_strategy` 'e2e' | 'tpot' — What metrics to use for latency. Available values are: `tpot` (time-per-output-token) and `e2e`.
      - `read_timeout` integer
      - `retries` integer — The number of retries to execute upon failure to proxy.
      - `slots` integer — The number of slots in the load balancer algorithm.
      - `tokens_count_strategy` 'completion-tokens' | 'cost' | 'prompt-tokens' | 'total-tokens' — What tokens to use for usage calculation. Available values are: `total_tokens` `prompt_tokens`, `completion_tokens` and `cost`.
      - `write_timeout` integer
    - `embeddings` object
      - `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_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'.
      - `model` object, required
        - `name` string, required — Model name to execute.
        - `options` object — Key/value settings for the model
          - `azure` object, required
            - `api_version` string — 'api-version' for Azure OpenAI instances.
            - `deployment_id` string — Deployment ID for Azure OpenAI instances.
            - `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.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `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
          - `upstream_url` string — upstream url for the embeddings
        - `provider` 'azure' | 'bedrock' | 'gemini' | 'huggingface' | 'mistral' | 'openai', required — AI provider format to use for embeddings API
    - `llm_format` 'bedrock' | 'gemini' | 'openai' — LLM input and output format and schema to use
    - `max_request_body_size` integer — max allowed body size allowed to be introspected
    - `model_name_header` boolean — Display the model name selected in the X-Kong-LLM-Model response header
    - `response_streaming` 'allow' | 'always' | 'deny' — Whether to 'optionally allow', 'deny', or 'always' (force) the streaming of answers via server sent events.
    - `targets` object[]
      - `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_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.
      - `logging` object, required
        - `log_payloads` boolean — If enabled, will log the request and response body into the Kong log plugin(s) output.
        - `log_statistics` boolean — If enabled and supported by the driver, will add model usage and token metrics into the Kong log plugin(s) output.
      - `model` object, required
        - `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.
          - `gemini` object
            - `api_endpoint` string — If running Gemini on Vertex, specify the regional API endpoint (hostname only).
            - `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' | 'cohere' | 'gemini' | 'huggingface' | 'llama2' | 'mistral' | 'openai', required — AI provider request format - Kong translates requests to and from the specified backend compatible formats.
      - `route_type` 'llm/v1/chat' | 'llm/v1/completions' | 'preserve', required — The model's operation implementation, for this provider. Set to `preserve` to pass through without transformation.
      - `weight` integer — The weight this target gets within the upstream loadbalancer (1-65535).
    - `vectordb` object
      - `dimensions` integer, required — the desired dimensionality for the vectors
      - `distance_metric` 'cosine' | 'euclidean', required — the distance metric to use for vector searches
      - `pgvector` object, required
        - `database` string — the database of the pgvector database
        - `host` string — the host of the pgvector database
        - `password` string — the password of the pgvector database
        - `port` integer — the port of the pgvector database
        - `ssl` boolean — whether to use ssl for the pgvector database
        - `ssl_cert` string — the path of ssl cert to use for the pgvector database
        - `ssl_cert_key` string — the path of ssl cert key to use for the pgvector database
        - `ssl_required` boolean — whether ssl is required for the pgvector database
        - `ssl_verify` boolean — whether to verify ssl for the pgvector database
        - `ssl_version` 'any' | 'tlsv1_2' | 'tlsv1_3' — the ssl version to use for the pgvector database
        - `timeout` number — the timeout of the pgvector database
        - `user` string — the user of the pgvector database
      - `redis` object, required
        - `cluster_max_redirections` integer — Maximum retry attempts for redirection.
        - `cluster_nodes` object[] — Cluster addresses to use for Redis connections when the `redis` strategy is defined. Defining this field implies using a Redis Cluster. The minimum length of the array is 1 element.
          - `ip` string — A string representing a host name, such as example.com.
          - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `connect_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `connection_is_proxied` boolean — If the connection to Redis is proxied (e.g. Envoy), set it `true`. Set the `host` and `port` to point to the proxy address.
        - `database` integer — Database to use for the Redis connection when using the `redis` strategy
        - `host` string — A string representing a host name, such as example.com.
        - `keepalive_backlog` integer — Limits the total number of opened connections for a pool. If the connection pool is full, connection queues above the limit go into the backlog queue. If the backlog queue is full, subsequent connect operations fail and return `nil`. Queued operations (subject to set timeouts) resume once the number of connections in the pool is less than `keepalive_pool_size`. If latency is high or throughput is low, try increasing this value. Empirically, this value is larger than `keepalive_pool_size`.
        - `keepalive_pool_size` integer — The size limit for every cosocket connection pool associated with every remote server, per worker process. If neither `keepalive_pool_size` nor `keepalive_backlog` is specified, no pool is created. If `keepalive_pool_size` isn't specified but `keepalive_backlog` is specified, then the pool uses the default value. Try to increase (e.g. 512) this value if latency is high or throughput is low.
        - `password` string — Password to use for Redis connections. If undefined, no AUTH commands are sent to Redis.
        - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `read_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `send_timeout` integer — An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.
        - `sentinel_master` string — Sentinel master to use for Redis connections. Defining this value implies using Redis Sentinel.
        - `sentinel_nodes` object[] — Sentinel node addresses to use for Redis connections when the `redis` strategy is defined. Defining this field implies using a Redis Sentinel. The minimum length of the array is 1 element.
          - `host` string — A string representing a host name, such as example.com.
          - `port` integer — An integer representing a port number between 0 and 65535, inclusive.
        - `sentinel_password` string — Sentinel password to authenticate with a Redis Sentinel instance. If undefined, no AUTH commands are sent to Redis Sentinels.
        - `sentinel_role` 'any' | 'master' | 'slave' — Sentinel role to use for Redis connections when the `redis` strategy is defined. Defining this value implies using Redis Sentinel.
        - `sentinel_username` string — Sentinel username to authenticate with a Redis Sentinel instance. If undefined, ACL authentication won't be performed. This requires Redis v6.2.0+.
        - `server_name` string — A string representing an SNI (server name indication) value for TLS.
        - `ssl` boolean — If set to true, uses SSL to connect to Redis.
        - `ssl_verify` boolean — If set to true, verifies the validity of the server SSL certificate. If setting this parameter, also configure `lua_ssl_trusted_certificate` in `kong.conf` to specify the CA (or server) certificate used by your Redis server. You may also need to configure `lua_ssl_verify_depth` accordingly.
        - `username` string — Username to use for Redis connections. If undefined, ACL authentication won't be performed. This requires Redis v6.0.0+. To be compatible with Redis v5.x.y, you can set it to `default`.
      - `strategy` 'pgvector' | 'redis', required — which vector database driver to use
      - `threshold` number, required — the default similarity threshold for accepting semantic search results (float)
  - `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

## Changes

> 7 revisions in range; 1 not diffed.

- **2025-05-01** `daef3e27adf6` — 2 breaking, 7 warning, 27 info
  - added the new required request property `allOf[#/components/schemas/AiProxyAdvancedPluginConfig]/config/embeddings/model/options/azure`
  - added the new required request property `allOf[#/components/schemas/AiProxyAdvancedPluginConfig]/config/vectordb/pgvector`
  - added the new `azure` enum value to the `allOf[#/components/schemas/AiProxyAdvancedPluginConfig]/config/embeddings/model/provider` response property for the response status `201`
  - added the new `bedrock` enum value to the `allOf[#/components/schemas/AiProxyAdvancedPluginConfig]/config/embeddings/model/provider` response property for the response status `201`
  - …32 more
- **2025-04-04** `e07a25288f1f` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/kong/apis/kong-enterprise-admin-api/changes/plugins#AiProxyAdvanced/post.md)

---

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