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

AI 응답 변환 정책 구성 레퍼런스

원문 보기 위키 갱신

AI 응답 변환 정책 구성 레퍼런스 (AI Response Transformer Policy Configuration Reference)

이 문서는 Kong AI Gateway에서 AI Response Transformer 정책을 구성할 때 참고하는 설정 항목들을 스키마 형태로 정리한 레퍼런스예요. 요청 본문 최대 크기(max_request_body_size), 포워드 프록시 인증과 프록시 호스트 설정, LLM 라우트 타입 같은 주요 속성이 각각 어떤 역할을 하는지 하나씩 설명해 줘요. 정책을 새로 구성하거나 기존 설정을 조정할 때 각 필드에 어떤 값을 넣어야 할지 확인하는 용도로 활용하면 좋아요

출처: 문서

본문

{
  "properties": {
    "config": {
      "type": "object",
      "properties": {
        "max_request_body_size": {
          "type": "integer",
          "description": "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.",
          "default": 8388608
        },
        "proxy_config": {
          "type": "object",
          "properties": {
            "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."
            },
            "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"
            }
          }
        },
        "llm": {
          "type": "object",
          "properties": {
            "route_type": {
              "type": "string",
              "enum": [
                "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",
                "llm/v1/skills",
                "passthrough",
                "realtime/v1/realtime",
                "video/v1/videos/generations"
              ],
              "description": "The model's operation implementation, for this provider. "
            },
            "auth": {
              "type": "object",
              "properties": {
                "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
                },
                "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
                },
                "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
                },
                "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
                },
                "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."
                },
                "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_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
                },
                "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
                },
                "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
                },
                "header_name": {
                  "type": "string",
                  "description": "If AI model requires authentication via Authorization or API key header, specify its name here.",
                  "x-referenceable": true
                },
                "param_name": {
                  "type": "string",
                  "description": "If AI model requires authentication via query parameter, specify its name here.",
                  "x-referenceable": true
                },
                "param_value": {
                  "type": "string",
                  "description": "Specify the full parameter value for 'param_name'.",
                  "x-referenceable": true,
                  "x-encrypted": true
                },
                "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
                },
                "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
                },
                "header_value": {
                  "type": "string",
                  "description": "Specify the full auth header value for 'header_name', for example 'Bearer key' or just 'key'.",
                  "x-encrypted": true,
                  "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-referenceable": true,
                  "x-encrypted": true
                },
                "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
                },
                "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
                }
              }
            },
            "model": {
              "type": "object",
              "properties": {
                "provider": {
                  "type": "string",
                  "enum": [
                    "anthropic",
                    "azure",
                    "bedrock",
                    "cerebras",
                    "cohere",
                    "dashscope",
                    "databricks",
                    "deepseek",
                    "gemini",
                    "huggingface",
                    "kimi",
                    "llama2",
                    "mistral",
                    "ollama",
                    "openai",
                    "sagemaker",
                    "typesafe",
                    "vercel",
                    "vllm",
                    "xai"
                  ],
                  "description": "AI provider request format - Kong translates requests to and from the specified backend compatible formats."
                },
                "name": {
                  "type": "string",
                  "description": "Model name to execute."
                },
                "model_alias": {
                  "type": "string",
                  "description": "The model name parameter from the request that this model should map to."
                },
                "options": {
                  "type": "object",
                  "properties": {
                    "azure_foundry_domain": {
                      "type": "string",
                      "description": "Domain for Azure Foundry hosted models.",
                      "default": "services.ai.azure.com"
                    },
                    "azure_foundry_path_prefix": {
                      "type": "string",
                      "enum": [
                        "/anthropic/v1",
                        "/openai/v1"
                      ],
                      "description": "Path prefix for Azure Foundry hosted models.",
                      "default": "/openai/v1"
                    },
                    "llama2_format": {
                      "type": "string",
                      "enum": [
                        "ollama",
                        "openai",
                        "raw"
                      ],
                      "description": "If using llama2 provider, select the upstream message format."
                    },
                    "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."
                        },
                        "endpoint_id": {
                          "type": "string",
                          "description": "If running Gemini on Vertex Model Garden, specify the endpoint ID."
                        }
                      }
                    },
                    "databricks": {
                      "type": "object",
                      "properties": {
                        "workspace_instance_id": {
                          "type": "string",
                          "description": "Workspace Instance ID ('dbc-xxx-yyy') for Databricks model serving."
                        }
                      }
                    },
                    "max_tokens": {
                      "type": "integer",
                      "description": "Defines the max_tokens, if using chat or completion models."
                    },
                    "cache_read_cost": {
                      "type": "number",
                      "description": "Defines the cost per 1M cache-read (cached) prompt tokens."
                    },
                    "cache_read_cost_list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "modal": {
                            "type": "string",
                            "enum": [
                              "audio",
                              "image",
                              "text",
                              "video"
                            ]
                          },
                          "cost": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "cost",
                          "modal"
                        ]
                      },
                      "description": "Per-modality override of `cache_read_cost`, in cost per 1M cache-read prompt tokens. Set it for models that price each modality separately."
                    },
                    "top_p": {
                      "type": "number",
                      "maximum": 1,
                      "minimum": 0,
                      "description": "Defines the top-p probability mass, if supported."
                    },
                    "azure_deployment_id": {
                      "type": "string",
                      "description": "Deployment ID for Azure OpenAI instances."
                    },
                    "cache_write_cost": {
                      "type": "number",
                      "description": "Defines the cost per 1M cache-write prompt tokens."
                    },
                    "input_cost_list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "modal": {
                            "type": "string",
                            "enum": [
                              "audio",
                              "image",
                              "text",
                              "video"
                            ]
                          },
                          "cost": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "cost",
                          "modal"
                        ]
                      },
                      "description": "Per-modality override of `input_cost`, in cost per 1M prompt tokens. Set it for models that price each modality separately."
                    },
                    "cache_write_cost_list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "ttl": {
                            "type": "string"
                          },
                          "cost": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "cost",
                          "ttl"
                        ]
                      },
                      "description": "Per-cache-TTL cache-write pricing; overrides cache_write_cost per TTL. Configure this if the upstream provider charges differently for different cache TTLs, as Anthropic does for 5m and 1h TTLs."
                    },
                    "azure_instance": {
                      "type": "string",
                      "description": "Instance name for Azure OpenAI hosted models."
                    },
                    "mistral_format": {
                      "type": "string",
                      "enum": [
                        "ollama",
                        "openai"
                      ],
                      "description": "If using mistral provider, select the upstream message format."
                    },
                    "embeddings_dimensions": {
                      "type": "integer",
                      "description": "If using embeddings models, set the number of dimensions to generate."
                    },
                    "input_cost": {
                      "type": "number",
                      "description": "Defines the cost per 1M tokens in your prompt."
                    },
                    "output_cost_list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "modal": {
                            "type": "string",
                            "enum": [
                              "audio",
                              "image",
                              "text",
                              "video"
                            ]
                          },
                          "cost": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "cost",
                          "modal"
                        ]
                      },
                      "description": "Per-modality override of `output_cost`, in cost per 1M output tokens. Set it for models that price each modality separately."
                    },
                    "service_tier_factor": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "tier": {
                            "type": "string",
                            "minLength": 1,
                            "description": "A word matched case-insensitively as a substring of the vendor's reported service tier (e.g. 'priority', 'flex', or 'throughput' for Gemini/Vertex's PROVISIONED_THROUGHPUT). If several entries match, the longest (most specific) wins; array order doesn't matter. Configure 'priority' will also match 'fast' (whole word) as OpenAI returns either 'priority' or 'fast' for priority service tier."
                          },
                          "factor": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "factor",
                          "tier"
                        ]
                      },
                      "description": "Multiplier applied to the whole request for a service tier. No need to configure a standard/default tier, as the default factor is 1.0 if none of the tier is matched."
                    },
                    "top_k": {
                      "type": "integer",
                      "maximum": 500,
                      "minimum": 0,
                      "description": "Defines the top-k most likely tokens, if supported."
                    },
                    "azure_service": {
                      "type": "string",
                      "enum": [
                        "azure-foundry",
                        "azure-openai"
                      ],
                      "description": "Service type for Azure provider models.",
                      "default": "azure-openai"
                    },
                    "dashscope": {
                      "type": "object",
                      "properties": {
                        "international": {
                          "type": "boolean",
                          "description": "Two Dashscope endpoints are available, and the international endpoint will be used when this is set to `true`.\nIt is recommended to set this to `true` when using international version of dashscope.\n",
                          "default": true
                        }
                      }
                    },
                    "bedrock": {
                      "type": "object",
                      "properties": {
                        "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."
                        },
                        "batch_role_arn": {
                          "type": "string",
                          "description": "AWS role arn used for calling batch API. Try to get the value from request if ommited."
                        },
                        "aws_role_session_name": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock), set the identifier of the assumed role session."
                        },
                        "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."
                        },
                        "video_output_s3_uri": {
                          "type": "string",
                          "description": "S3 URI (s3://bucket/prefix) where Bedrock will store generated video files. Required for video generation."
                        },
                        "aws_region": {
                          "type": "string",
                          "description": "If using AWS providers (Bedrock) you can override the `AWS_REGION` environment variable by setting this option."
                        },
                        "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_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
                        }
                      }
                    },
                    "huggingface": {
                      "type": "object",
                      "properties": {
                        "wait_for_model": {
                          "type": "boolean",
                          "description": "Wait for the model if it is not ready"
                        },
                        "use_cache": {
                          "type": "boolean",
                          "description": "Use the cache layer on the inference API"
                        }
                      }
                    },
                    "cohere": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "enum": [
                            "v1",
                            "v2"
                          ],
                          "description": "Cohere API version for chat route type: v1 (legacy, /v1/chat) or v2 (default, /v2/chat, supports tools).",
                          "default": "v2"
                        },
                        "embedding_input_type": {
                          "type": "string",
                          "enum": [
                            "classification",
                            "clustering",
                            "image",
                            "search_document",
                            "search_query"
                          ],
                          "description": "The purpose of the input text to calculate embedding vectors.",
                          "default": "classification"
                        },
                        "wait_for_model": {
                          "type": "boolean",
                          "description": "Wait for the model if it is not ready"
                        }
                      }
                    },
                    "kimi": {
                      "type": "object",
                      "properties": {
                        "international": {
                          "type": "boolean",
                          "description": "Two Kimi/Moonshot AI endpoints are available: `api.moonshot.cn` (mainland China) and\n`api.moonshot.ai` (international, default). Set this to `false` to use the mainland China endpoint.\n",
                          "default": true
                        }
                      }
                    },
                    "azure_foundry_resource": {
                      "type": "string",
                      "description": "Resource name for Azure Foundry hosted models."
                    },
                    "sagemaker": {
                      "type": "object",
                      "properties": {
                        "aws_assume_role_arn": {
                          "type": "string",
                          "description": "Assume a different IAM role after authentication."
                        },
                        "aws_role_session_name": {
                          "type": "string",
                          "description": "Identifier for the assumed role session."
                        },
                        "aws_sts_endpoint_url": {
                          "type": "string",
                          "description": "Override the STS endpoint URL when assuming a different role."
                        },
                        "target_model": {
                          "type": "string",
                          "description": "Sets the X-Amzn-SageMaker-Target-Model header for multi-model endpoints."
                        },
                        "target_variant": {
                          "type": "string",
                          "description": "Sets the X-Amzn-SageMaker-Target-Variant header for A/B variant testing."
                        },
                        "target_container_hostname": {
                          "type": "string",
                          "description": "Sets the X-Amzn-SageMaker-Target-Container-Hostname header for multi-container endpoints."
                        },
                        "aws_region": {
                          "type": "string",
                          "description": "Override the `AWS_REGION` environment variable for SageMaker requests."
                        }
                      }
                    },
                    "upstream_url": {
                      "type": "string",
                      "description": "Manually specify or override the full URL to the AI operation endpoints, when calling (self-)hosted models, or for running via a private endpoint. Variable substitution is supported. Warning: if variable substitution is used, please verify that the client is from a trusted source to prevent injection."
                    },
                    "output_cost": {
                      "type": "number",
                      "description": "Defines the cost per 1M tokens in the output of the AI."
                    },
                    "context_window_factor": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "input_factor": {
                            "type": "number"
                          },
                          "output_factor": {
                            "type": "number"
                          },
                          "above": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "above",
                          "input_factor",
                          "output_factor"
                        ]
                      },
                      "description": "Above an input-token threshold, scale input/output pricing with the corresponding factor."
                    },
                    "temperature": {
                      "type": "number",
                      "maximum": 5,
                      "minimum": 0,
                      "description": "Defines the matching temperature, if using chat or completion models."
                    },
                    "anthropic_version": {
                      "type": "string",
                      "description": "Defines the schema/API version, if using Anthropic provider."
                    },
                    "azure_api_version": {
                      "type": "string",
                      "description": "'api-version' for Azure OpenAI instances.",
                      "default": "2023-05-15"
                    }
                  },
                  "description": "Key/value settings for the model"
                }
              },
              "required": [
                "provider"
              ]
            },
            "logging": {
              "type": "object",
              "properties": {
                "log_statistics": {
                  "type": "boolean",
                  "description": "If enabled and supported by the driver, will add model usage and token metrics into the Kong log policy(s) output.",
                  "default": false
                },
                "log_payloads": {
                  "type": "boolean",
                  "description": "If enabled, will log the request and response body into the Kong log policy(s) output.Furthermore if Opentelemetry instrumentation is enabled the traces will contain this data as well.",
                  "default": false
                },
                "opentelemetry_attribute_keys_format": {
                  "type": "string",
                  "enum": [
                    "openinference",
                    "openllmetry"
                  ],
                  "description": "Sets the keys standard to be used for OpenTelemetry trace attributes and metrics.",
                  "default": "openllmetry"
                }
              }
            },
            "weight": {
              "type": "integer",
              "maximum": 65535,
              "minimum": 1,
              "description": "The weight this target gets within the upstream loadbalancer (1-65535). Only used by ai-proxy-advanced.",
              "default": 100
            },
            "description": {
              "type": "string",
              "description": "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."
            },
            "metadata": {
              "type": "object",
              "additionalProperties": true,
              "description": "For internal use only. ",
              "nullable": true,
              "x-speakeasy-type-override": "any"
            }
          },
          "required": [
            "model",
            "route_type"
          ]
        },
        "prompt": {
          "type": "string",
          "description": "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": {
          "type": "string",
          "description": "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."
        },
        "parse_llm_response_json_instructions": {
          "type": "boolean",
          "description": "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 policy docs 'Overview' page for usage instructions.",
          "default": false
        },
        "http_timeout": {
          "type": "integer",
          "description": "Timeout in milliseconds for the AI upstream service.",
          "default": 60000
        },
        "https_verify": {
          "type": "boolean",
          "description": "Verify the TLS certificate of the AI upstream service.",
          "default": true
        }
      },
      "required": [
        "llm",
        "prompt"
      ]
    }
  }
}

번역할 문서 조각이 아직 첨부되지 않았어요. Kong 문서 내용을 보내주시면 규칙에 맞게 바로 번역해 드릴게요.

관련 리소스

더 알아보기 (Learn more)

  • AI Response Transformer 정책과 세트로 사용하는 요청 측 변환 정책의 설정을 다루는 문서예요, 요청과 응답을 함께 처리할 때 참고하면 좋아요 — AI Request Transformer Policy