跳到主要内容

参数

请参阅 插件通用配置 了解所有插件可用的配置选项。

  • provider

    string


    required


    vaild vaule:

    openai, deepseek, azure-openai, aimlapi, gemini, vertex-ai, anthropic, openrouter, openai-compatible


    LLM 服务提供商。

    当设置为 openai 时,插件将代理请求到 https://api.openai.com/chat/completions

    当设置为 deepseek 时,插件将代理请求到 https://api.deepseek.com/chat/completions

    当设置为 gemini(API7 企业版 3.9.3 及更高版本)时,插件将代理请求到 https://generativelanguage.googleapis.com/v1beta/openai/chat/completions。如果你代理请求到嵌入模型,则应在 override 中配置嵌入模型端点。

    当设置为 vertex-ai(API7 企业版 3.9.3 及更高版本)时,插件代理请求到 Google Cloud Vertex AI。对于聊天补全,插件将代理请求到 https://{region}-aiplatform.googleapis.com/v1beta1/projects/{project_id}/locations/{region}/endpoints/openapi/chat/completions。对于嵌入,插件将代理请求到 https://{region}-aiplatform.googleapis.com/v1/projects/{project_id}/locations/{region}/publishers/google/models/{model}:predict。这些需要配置 provider_conf 中的 project_idregion。或者,你可以配置 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


      认证头。headerquery 中至少应配置一个。

    • query

      object


      认证查询参数。headerquery 中至少应配置一个。

    • gcp

      object


      Vertex AI 的 GCP 服务账号认证。在 API7 企业版 3.9.3 及更高版本中可用,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,你可以配置 temperaturetop_pstream 等其他参数。有关更多可用选项,请参阅你的 LLM 提供商的 API 文档。

    • model

      string


      LLM 模型的名称,例如 gpt-4gpt-3.5。有关更多可用模型,请参阅你的 LLM 提供商的 API 文档。

  • provider_conf

    object


    提供商特定的配置。当 providervertex-ai 时,应配置 provider_confoverride 之一。

    在 API7 企业版 3.9.3 及更高版本中可用,APISIX 中不可用。

    • project_id

      string


      required


      Vertex AI 的 Google Cloud 项目 ID。

    • region

      string


      required


      Vertex AI 的 Google Cloud 区域。

  • override

    object


    覆盖设置。

    • endpoint

      string


      LLM 提供商端点。当 provideropenai-compatible 时必填。

  • timeout

    integer


    default: 30000


    vaild vaule:

    大于或等于 1


    请求 LLM 服务时的请求超时时间(以毫秒为单位)。

  • keepalive

    boolean


    default: true


    如果为 true,则在请求 LLM 服务时保持连接处于活动状态。

  • keepalive_timeout

    integer


    default: 60000


    vaild vaule:

    大于或等于 1000


    请求 LLM 服务时的请求超时时间(以毫秒为单位)。

  • keepalive_pool

    integer


    default: 30


    连接 LLM 服务时的 Keepalive 连接池大小。

  • ssl_verify

    boolean


    default: true


    如果为 true,则验证 LLM 服务的证书。