参数
请参阅 插件通用配置 了解所有插件可用的配置选项。
provider
string
required
vaild vaule:
openai,deepseek,azure-openai,aimlapi,gemini,vertex-ai,anthropic,openrouter,openai-compatibleLLM 服务提供商。
当设置为
openai时,插件将请求代理到https://api.openai.com/chat/completions。当设置为
deepseek时,插件将请求代理到https://api.deepseek.com/chat/completions。当设置为
gemini(API7 企业版 3.9.2 及更高版本) 时,插件将请求代理到https://generativelanguage.googleapis.com/v1beta/openai/chat/completions。如果代理请求到 Embedding 模型,则应在override中配置 Embedding 模型端点。当设置为
vertex-ai(API7 企业版 3.9.2 及更高版本) 时,插件将请求代理到 Google Cloud Vertex AI。对于 聊天完成,插件将请求代理到https://{region}-aiplatform.googleapis.com/v1beta1/projects/{project_id}/locations/{region}/endpoints/openapi/chat/completions。对于 Embedding,插件将请求代理到https://{region}-aiplatform.googleapis.com/v1/projects/{project_id}/locations/{region}/publishers/google/models/{model}:predict。这些需要配置provider_conf中的project_id和region。或者,你可以在override中配置自定义端点。当设置为
anthropic(API7 企业版 3.9.2 及更高版本) 时,插件将请求代理到https://api.anthropic.com/v1/chat/completions。当设置为
openrouter(API7 企业版 3.9.2 及更高版本) 时,插件将请求代理到https://openrouter.ai/api/v1/chat/completions。当设置为
aimlapi时,插件默认使用 OpenAI 兼容驱动程序并将请求代理到https://api.aimlapi.com/v1/chat/completions。此参数从 APISIX 3.15.0 版本和 API7 企业版 3.8.17 版本开始可用。当设置为
openai-compatible时,插件将请求代理到override中配置的自定义端点。当设置为
azure-openai时,插件也会将请求代理到override中配置的自定义端点,并另外从用户请求中移除model参数。auth
object
required
认证配置。
header
object
认证头。必须至少配置
header和query中的一个。query
object
认证查询参数。必须至少配置
header和query中的一个。gcp
object
Vertex AI 的 GCP 服务账号认证。在 API7 企业版 3.9.2 及更高版本中可用,在 APISIX 中不可用。
service_account_json
string
用于认证的 GCP 服务账号 JSON 内容。可以使用此参数配置,也可以通过设置
GCP_SERVICE_ACCOUNT环境变量来配置。max_ttl
integer
GCP 访问令牌缓存的最大 TTL(秒)。
expire_early_secs
integer
default:
60在实际过期时间之前使访问令牌过期的秒数。这可以防止在活动请求期间令牌过期的边缘情况。
options
object
模型配 置。
除了
model之外,你还可以配置其他参数,它们将在请求体中转发到上游 LLM 服务。例如,如果你使用 OpenAI,你可以配置temperature、top_p和stream等附加参数。更多可用选项请参见你的 LLM 提供商的 API 文档。model
string
LLM 模型名称,例如
gpt-4或gpt-3.5。更多可用模型请参见你的 LLM 提供商 API 文档。
provider_conf
object
提供商特定配置。当
provider为vertex-ai时,必须配置provider_conf或override之一。在 API7 企业版 3.9.2 及更高版本中可用,在 APISIX 中不可用。
project_id
string
required
Vertex AI 的 Google Cloud Project ID。
region
string
required
Vertex AI 的 Google Cloud Region。
override
object
覆盖设置。
endpoint
string
LLM 提供商端点。当
provider为openai-compatible时必填。llm_options
object
感知提供商的 LLM 选项覆盖。自 API7 Enterprise 版本 3.9.10 起可用,APISIX 中暂不可用 。
max_tokens
integer
最大输出 token 数。网关自动将此值映射为目标提供商的正确字段名(例如 OpenAI Chat 的
max_completion_tokens,OpenAI Responses API 的max_output_tokens)。始终强制覆盖客户端值。
request_body
object
按目标协议的请求体覆盖。键为目标协议名称(
openai-chat、openai-responses、openai-embeddings、anthropic-messages);值为部分请求体,深度合并到发出的请求体中(对象递归合并,数组和标量整体替换)。自 API7 Enterprise 版本 3.9.10 起可用,APISIX 中暂不可用。request_body_force_override
boolean
default:
false当为
false(默认)时,客户端请求体字段优先,request_body覆盖值仅填充缺失字段。当为true时,request_body覆盖值强制覆盖客户端字段。自 API7 Enterprise 版本 3.9.10 起可用,APISIX 中暂不可用。
logging
object
日志配置。
summaries
boolean
default:
false如果为 true,记录请求 LLM 模型、持续时间、请求和响应 Token。
payloads
boolean
default:
false如果为 true,记录请求和响应 Payload。
timeout
integer
default:
30000vaild vaule:
greater than or equal to 1
请求 LLM 服务时的请求超时时间(毫秒)。
keepalive
boolean
default:
true如果为 true,在请求 LLM 服务时保持连接活动。
keepalive_timeout
integer
default:
60000vaild vaule:
greater than or equal to 1000
请求 LLM 服务时的 Keepalive 超时时间(毫秒)。
keepalive_pool
integer
default:
30连接 LLM 服务时的 Keepalive 连接池大小。
ssl_verify
boolean
default:
true如果为 true,验证 LLM 服务的证书。
max_stream_duration_ms
integer
流式 AI 响应的最大持续时间(毫秒)。如果上游持续发送数据超过此期限,连接将被关闭。未设置表示无上限。用于保护网关免受无限生成 token 的上游异常影响。自 API7 Enterprise 版本 3.9.10 起可用,APISIX 中暂不可用。
max_response_bytes
integer
单个 AI 响应(流式或非流式)从上游读取的最大总字节数。超出后连接将被关闭。未设置表示无上限。自 API7 Enterprise 版本 3.9.10 起可用,APISIX 中暂不可用。