본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

AI 시맨틱 캐시 정책 구성 레퍼런스

원문 보기 위키 갱신

AI 시맨틱 캐시 정책 구성 레퍼런스 (AI Semantic Cache Policy Configuration Reference)

이 문서는 Kong AI Gateway의 AI 시맨틱 캐시 정책에서 설정할 수 있는 구성 옵션을 하나하나 정리한 레퍼런스예요. 캐시 항목의 TTL이나 Cache-Control 동작, LLM 입출력 형식 같은 기본 설정부터 시맨틱 매칭에 사용되는 임베딩 모델 구성까지 각 필드의 타입과 기본값, 동작 방식을 확인할 수 있어요. 정책을 내 서비스 환경에 맞게 튜닝할 때 옆에 두고 참고하기 딱 좋은 문서예요

출처: 문서

본문

{
  "properties": {
    "config": {
      "type": "object",
      "properties": {
        "ignore_system_prompts": {
          "type": "boolean",
          "description": "Ignore and discard any system prompts when Vectorizing the request",
          "default": false
        },
        "stop_on_failure": {
          "type": "boolean",
          "description": "Halt the LLM request process in case of a caching system failure",
          "default": false
        },
        "cache_ttl": {
          "type": "integer",
          "description": "TTL in seconds of cache entities. Must be a value greater than 0.",
          "default": 300
        },
        "cache_control": {
          "type": "boolean",
          "description": "When enabled, respect the Cache-Control behaviors defined in RFC7234.",
          "default": false
        },
        "llm_format": {
          "type": "string",
          "enum": [
            "anthropic",
            "bedrock",
            "cohere",
            "gemini",
            "huggingface",
            "openai",
            "typesafe"
          ],
          "description": "LLM input and output format and schema to use",
          "default": "openai"
        },
        "embeddings": {
          "type": "object",
          "properties": {
            "model": {
              "type": "object",
              "properties": {
                "provider": {
                  "type": "string",
                  "enum": [
                    "azure",
                    "bedrock",
                    "databricks",
                    "gemini",
                    "huggingface",
                    "mistral",
                    "ollama",
                    "openai",
                    "vercel"
                  ],
                  "description": "AI provider format to use for embeddings API"
                },
                "name": {
                  "type": "string",
                  "description": "Model name to execute."
                },
                "options": {
                  "type": "object",
                  "properties": {
                    "bedrock": {
                      "type": "object",
                      "properties": {
                        "aws_assume_role_arn": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock) you can assume a different role after authentication with the current IAM context is successful."
                        },
                        "aws_role_session_name": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock), set the identifier of the assumed role session."
                        },
                        "aws_sts_endpoint_url": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock), override the STS endpoint URL when assuming a different role."
                        },
                        "embeddings_normalize": {
                          "type": "boolean",
                          "description": "If using AWS providers (Bedrock), set to true to normalize the embeddings.",
                          "default": false
                        },
                        "video_output_s3_uri": {
                          "type": "string",
                          "description": "S3 URI (s3://bucket/prefix) where Bedrock will store generated video files. Required for video generation."
                        },
                        "batch_role_arn": {
                          "type": "string",
                          "description": "AWS role arn used for calling batch API. Try to get the value from request if ommited."
                        },
                        "aws_region": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock) you can override the `AWS_REGION` environment variable by setting this option."
                        },
                        "performance_config_latency": {
                          "type": "string",
                          "description": "Force the client's performance configuration 'latency' for all requests. Leave empty to let the consumer select the performance configuration."
                        },
                        "batch_bucket_prefix": {
                          "type": "string",
                          "description": "S3 URI prefix (s3://bucket/prefix/) where Bedrock will get input files from and store results to for native batch API."
                        }
                      }
                    },
                    "gemini": {
                      "type": "object",
                      "properties": {
                        "api_endpoint": {
                          "type": "string",
                          "description": "If running Gemini on Vertex, specify the regional API endpoint (hostname only)."
                        },
                        "project_id": {
                          "type": "string",
                          "description": "If running Gemini on Vertex, specify the project ID."
                        },
                        "location_id": {
                          "type": "string",
                          "description": "If running Gemini on Vertex, specify the location ID."
                        }
                      }
                    },
                    "huggingface": {
                      "type": "object",
                      "properties": {
                        "use_cache": {
                          "type": "boolean",
                          "description": "Use the cache layer on the inference API"
                        },
                        "wait_for_model": {
                          "type": "boolean",
                          "description": "Wait for the model if it is not ready"
                        }
                      }
                    },
                    "databricks": {
                      "type": "object",
                      "properties": {
                        "workspace_instance_id": {
                          "type": "string",
                          "description": "Workspace Instance ID ('dbc-xxx-yyy') for Databricks model serving."
                        }
                      }
                    },
                    "upstream_url": {
                      "type": "string",
                      "description": "upstream url for the embeddings"
                    },
                    "azure": {
                      "type": "object",
                      "properties": {
                        "instance": {
                          "type": "string",
                          "description": "Instance name for Azure OpenAI hosted models."
                        },
                        "api_version": {
                          "type": "string",
                          "description": "'api-version' for Azure OpenAI instances.",
                          "default": "2023-05-15"
                        },
                        "deployment_id": {
                          "type": "string",
                          "description": "Deployment ID for Azure OpenAI instances."
                        }
                      }
                    }
                  },
                  "description": "Key/value settings for the model"
                }
              },
              "required": [
                "name",
                "provider"
              ]
            },
            "auth": {
              "type": "object",
              "properties": {
                "gcp_workload_identity_federation_auth_json": {
                  "type": "string",
                  "description": "Set this if you are using an GCP provider (Gemini) and you are authenticating using Workload Identity Federation. This is the JSON string configuration for the federation operation. If unset, Kong will attempt to read the file path from the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, which should subsequently point to a Workfload Identity auth JSON file.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "azure_use_managed_identity": {
                  "type": "boolean",
                  "description": "Set true to use the Azure Cloud Managed Identity (or user-assigned identity) to authenticate with Azure-provider models.",
                  "default": false
                },
                "gcp_metadata_url": {
                  "type": "string",
                  "description": "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.",
                  "x-referenceable": true
                },
                "aws_session_token": {
                  "type": "string",
                  "description": "Set this if you are using an AWS provider (Bedrock) and you are authenticating using temporary IAM credentials (for example issued by AWS STS, Vault, or SSO/SAML). It is sent to AWS as the X-Amz-Security-Token header. Setting this will override the AWS_SESSION_TOKEN environment variable for this policy instance. Because temporary credentials are short-lived, reference this from a secrets backend so it is refreshed before it expires.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "header_name": {
                  "type": "string",
                  "description": "If AI model requires authentication via Authorization or API key header, specify its name here.",
                  "x-referenceable": true
                },
                "header_value": {
                  "type": "string",
                  "description": "Specify the full auth header value for 'header_name', for example 'Bearer key' or just 'key'.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "param_value": {
                  "type": "string",
                  "description": "Specify the full parameter value for 'param_name'.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "azure_client_id": {
                  "type": "string",
                  "description": "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.",
                  "x-referenceable": true
                },
                "gcp_service_account_json": {
                  "type": "string",
                  "description": "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`.",
                  "x-encrypted": true,
                  "x-referenceable": true
                },
                "aws_access_key_id": {
                  "type": "string",
                  "description": "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 policy instance.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "param_name": {
                  "type": "string",
                  "description": "If AI model requires authentication via query parameter, specify its name here.",
                  "x-referenceable": true
                },
                "param_location": {
                  "type": "string",
                  "enum": [
                    "body",
                    "query"
                  ],
                  "description": "Specify whether the 'param_name' and 'param_value' options go in a query string, or the POST form/JSON body."
                },
                "azure_client_secret": {
                  "type": "string",
                  "description": "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.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "azure_tenant_id": {
                  "type": "string",
                  "description": "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.",
                  "x-referenceable": true
                },
                "gcp_use_service_account": {
                  "type": "boolean",
                  "description": "Use service account auth for GCP-based providers and models.",
                  "default": false
                },
                "gcp_oauth_token_url": {
                  "type": "string",
                  "description": "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.",
                  "x-referenceable": true
                },
                "aws_secret_access_key": {
                  "type": "string",
                  "description": "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 policy instance.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "allow_override": {
                  "type": "boolean",
                  "description": "If enabled, the authorization header or parameter can be overridden in the request by the value configured in the policy.",
                  "default": false
                },
                "gcp_workload_identity_federation_source": {
                  "type": "string",
                  "enum": [
                    "aws_iam",
                    "off"
                  ],
                  "description": "Set this if you are using an GCP provider (Gemini) and you are authenticating using Workload Identity Federation. This is the source identity provider/system."
                }
              }
            }
          },
          "required": [
            "model"
          ]
        },
        "vectordb": {
          "type": "object",
          "properties": {
            "redis": {
              "type": "object",
              "properties": {
                "sentinel_master": {
                  "type": "string",
                  "description": "Sentinel master to use for Redis connections. Defining this value implies using Redis Sentinel."
                },
                "cluster_max_redirections": {
                  "type": "integer",
                  "description": "Maximum retry attempts for redirection.",
                  "default": 5
                },
                "host": {
                  "type": "string",
                  "description": "A string representing a host name, such as example.com.",
                  "default": "127.0.0.1",
                  "x-referenceable": true
                },
                "connect_timeout": {
                  "type": "integer",
                  "maximum": 2147483646,
                  "minimum": 0,
                  "description": "An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.",
                  "default": 2000
                },
                "username": {
                  "type": "string",
                  "description": "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`.",
                  "x-referenceable": true
                },
                "password": {
                  "type": "string",
                  "description": "Password to use for Redis connections. If undefined, no AUTH commands are sent to Redis.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "sentinel_password": {
                  "type": "string",
                  "description": "Sentinel password to authenticate with a Redis Sentinel instance. If undefined, no AUTH commands are sent to Redis Sentinels.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "cluster_nodes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ip": {
                        "type": "string",
                        "description": "A string representing a host name, such as example.com.",
                        "default": "127.0.0.1"
                      },
                      "port": {
                        "type": "integer",
                        "maximum": 65535,
                        "minimum": 0,
                        "description": "An integer representing a port number between 0 and 65535, inclusive.",
                        "default": 6379
                      }
                    }
                  },
                  "minLength": 1,
                  "description": "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."
                },
                "ssl": {
                  "type": "boolean",
                  "description": "If set to true, uses SSL to connect to Redis.",
                  "default": false
                },
                "server_name": {
                  "type": "string",
                  "description": "A string representing an SNI (server name indication) value for TLS.",
                  "x-referenceable": true
                },
                "port": {
                  "type": "integer",
                  "maximum": 65535,
                  "minimum": 0,
                  "description": "An integer representing a port number between 0 and 65535, inclusive.",
                  "default": 6379,
                  "x-referenceable": true
                },
                "read_timeout": {
                  "type": "integer",
                  "maximum": 2147483646,
                  "minimum": 0,
                  "description": "An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.",
                  "default": 2000
                },
                "database": {
                  "type": "integer",
                  "description": "Database to use for the Redis connection when using the `redis` strategy",
                  "default": 0
                },
                "keepalive_pool_size": {
                  "type": "integer",
                  "maximum": 2147483646,
                  "minimum": 1,
                  "description": "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.",
                  "default": 256
                },
                "keepalive_backlog": {
                  "type": "integer",
                  "maximum": 2147483646,
                  "minimum": 0,
                  "description": "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`."
                },
                "sentinel_role": {
                  "type": "string",
                  "enum": [
                    "any",
                    "master",
                    "slave"
                  ],
                  "description": "Sentinel role to use for Redis connections when the `redis` strategy is defined. Defining this value implies using Redis Sentinel."
                },
                "sentinel_nodes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "host": {
                        "type": "string",
                        "description": "A string representing a host name, such as example.com.",
                        "default": "127.0.0.1"
                      },
                      "port": {
                        "type": "integer",
                        "maximum": 65535,
                        "minimum": 0,
                        "description": "An integer representing a port number between 0 and 65535, inclusive.",
                        "default": 6379
                      }
                    }
                  },
                  "minLength": 1,
                  "description": "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."
                },
                "ssl_verify": {
                  "type": "boolean",
                  "description": "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.",
                  "default": true
                },
                "cloud_authentication": {
                  "type": "object",
                  "properties": {
                    "azure_tenant_id": {
                      "type": "string",
                      "description": "Azure Tenant ID to be used for authentication when `auth_provider` is set to `azure`.",
                      "x-encrypted": true,
                      "x-referenceable": true
                    },
                    "auth_provider": {
                      "type": "string",
                      "enum": [
                        "aws",
                        "azure",
                        "gcp"
                      ],
                      "description": "Auth providers to be used to authenticate to a Cloud Provider's Redis instance.",
                      "x-referenceable": true
                    },
                    "aws_secret_access_key": {
                      "type": "string",
                      "description": "AWS Secret Access Key to be used for authentication when `auth_provider` is set to `aws`.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "aws_assume_role_arn": {
                      "type": "string",
                      "description": "The ARN of the IAM role to assume for generating ElastiCache IAM authentication tokens.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "gcp_service_account_json": {
                      "type": "string",
                      "description": "GCP Service Account JSON to be used for authentication when `auth_provider` is set to `gcp`.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "azure_client_id": {
                      "type": "string",
                      "description": "Azure Client ID to be used for authentication when `auth_provider` is set to `azure`.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "azure_client_secret": {
                      "type": "string",
                      "description": "Azure Client Secret to be used for authentication when `auth_provider` is set to `azure`.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "aws_cache_name": {
                      "type": "string",
                      "description": "The name of the AWS Elasticache cluster when `auth_provider` is set to `aws`.",
                      "x-referenceable": true
                    },
                    "aws_region": {
                      "type": "string",
                      "description": "The region of the AWS ElastiCache cluster when `auth_provider` is set to `aws`.",
                      "x-referenceable": true
                    },
                    "aws_is_serverless": {
                      "type": "boolean",
                      "description": "This flag specifies whether the cluster is serverless when auth_provider is set to `aws`.",
                      "default": true
                    },
                    "aws_access_key_id": {
                      "type": "string",
                      "description": "AWS Access Key ID to be used for authentication when `auth_provider` is set to `aws`.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    },
                    "aws_role_session_name": {
                      "type": "string",
                      "description": "The session name for the temporary credentials when assuming the IAM role.",
                      "x-referenceable": true,
                      "x-encrypted": true
                    }
                  },
                  "description": "Cloud auth related configs for connecting to a Cloud Provider's Redis instance."
                },
                "connection_is_proxied": {
                  "type": "boolean",
                  "description": "If the connection to Redis is proxied (e.g. Envoy), set it `true`. Set the `host` and `port` to point to the proxy address.",
                  "default": false
                },
                "send_timeout": {
                  "type": "integer",
                  "maximum": 2147483646,
                  "minimum": 0,
                  "description": "An integer representing a timeout in milliseconds. Must be between 0 and 2^31-2.",
                  "default": 2000
                },
                "sentinel_username": {
                  "type": "string",
                  "description": "Sentinel username to authenticate with a Redis Sentinel instance. If undefined, ACL authentication won't be performed. This requires Redis v6.2.0+.",
                  "x-referenceable": true
                }
              }
            },
            "pgvector": {
              "type": "object",
              "properties": {
                "ssl": {
                  "type": "boolean",
                  "description": "whether to use ssl for the pgvector database",
                  "default": false
                },
                "ssl_version": {
                  "type": "string",
                  "enum": [
                    "any",
                    "tlsv1_2",
                    "tlsv1_3"
                  ],
                  "description": "the ssl version to use for the pgvector database",
                  "default": "tlsv1_2"
                },
                "ssl_cert": {
                  "type": "string",
                  "description": "the path of ssl cert to use for the pgvector database"
                },
                "host": {
                  "type": "string",
                  "description": "the host of the pgvector database",
                  "default": "127.0.0.1"
                },
                "port": {
                  "type": "integer",
                  "description": "the port of the pgvector database",
                  "default": 5432
                },
                "ssl_required": {
                  "type": "boolean",
                  "description": "whether ssl is required for the pgvector database",
                  "default": false
                },
                "ssl_verify": {
                  "type": "boolean",
                  "description": "whether to verify ssl for the pgvector database",
                  "default": true
                },
                "ssl_cert_key": {
                  "type": "string",
                  "description": "the path of ssl cert key to use for the pgvector database"
                },
                "user": {
                  "type": "string",
                  "description": "the user of the pgvector database",
                  "default": "postgres",
                  "x-referenceable": true
                },
                "password": {
                  "type": "string",
                  "description": "the password of the pgvector database",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "database": {
                  "type": "string",
                  "description": "the database of the pgvector database",
                  "default": "kong-pgvector"
                },
                "timeout": {
                  "type": "number",
                  "description": "the timeout of the pgvector database",
                  "default": 5000
                }
              }
            },
            "strategy": {
              "type": "string",
              "enum": [
                "pgvector",
                "redis"
              ],
              "description": "which vector database driver to use"
            },
            "dimensions": {
              "type": "integer",
              "description": "the desired dimensionality for the vectors"
            },
            "threshold": {
              "type": "number",
              "description": "the default similarity threshold for accepting semantic search results (float). Higher threshold means more results are considered similar."
            },
            "distance_metric": {
              "type": "string",
              "enum": [
                "cosine",
                "euclidean"
              ],
              "description": "the distance metric to use for vector searches"
            }
          },
          "required": [
            "dimensions",
            "distance_metric",
            "strategy"
          ]
        },
        "ignore_assistant_prompts": {
          "type": "boolean",
          "description": "Ignore and discard any assistant prompts when Vectorizing the request",
          "default": false
        },
        "ignore_tool_prompts": {
          "type": "boolean",
          "description": "Ignore and discard any tool prompts when Vectorizing the request",
          "default": false
        },
        "exact_caching": {
          "type": "boolean",
          "description": "When enabled, a first check for exact query will be done. It will impact DB size",
          "default": false
        },
        "proxy_config": {
          "type": "object",
          "properties": {
            "https_proxy_port": {
              "type": "integer",
              "maximum": 65535,
              "minimum": 0,
              "description": "An integer representing a port number between 0 and 65535, inclusive."
            },
            "proxy_scheme": {
              "type": "string",
              "enum": [
                "http"
              ],
              "description": "The proxy scheme to use when connecting. Only `http` is supported.",
              "default": "http"
            },
            "auth_username": {
              "type": "string",
              "description": "The username to authenticate with, if the forward proxy is protected by basic authentication.",
              "x-referenceable": true
            },
            "auth_password": {
              "type": "string",
              "description": "The password to authenticate with, if the forward proxy is protected by basic authentication.",
              "x-referenceable": true,
              "x-encrypted": true
            },
            "no_proxy": {
              "type": "string",
              "description": "Comma-separated list of hosts that should not be proxied."
            },
            "http_proxy_host": {
              "type": "string",
              "description": "A string representing a host name, such as example.com."
            },
            "http_proxy_port": {
              "type": "integer",
              "maximum": 65535,
              "minimum": 0,
              "description": "An integer representing a port number between 0 and 65535, inclusive."
            },
            "https_proxy_host": {
              "type": "string",
              "description": "A string representing a host name, such as example.com."
            }
          }
        },
        "message_countback": {
          "type": "number",
          "maximum": 1000,
          "minimum": 1,
          "description": "Number of messages in the chat history to Vectorize/Cache",
          "default": 1
        }
      },
      "required": [
        "embeddings",
        "vectordb"
      ]
    }
  }
}

번역할 문서 조각이 아직 첨부되지 않았어요. Kong 문서 내용(마크다운)을 보내주시면 규칙에 맞게 바로 번역할게요.

관련 리소스

더 알아보기 (Learn more)