Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Azure OpenAI 对象结构

将 Azure OpenAI Service 集成到您的应用程序中,使您能够无缝利用 Azure OpenAI 托管的多个部署和区域模型。本节详细介绍了如何根据您的需求配置 Azure OpenAI endpoint。

有关设置 Azure OpenAI 配置的详细指南,请点击此处

示例配置

endpoints:
  azureOpenAI:
    titleModel: "gpt-4-turbo"
    groups:
      - group: "my-westus" # arbitrary name
        apiKey: "${WESTUS_API_KEY}"
        instanceName: "actual-instance-name" # name of the resource group or instance
        version: "2023-12-01-preview"
        # baseURL: https://prod.example.com
        # additionalHeaders:
        #   X-Custom-Header: value
        models:
          gpt-4-vision-preview:
            deploymentName: gpt-4-vision-preview
            version: "2024-02-15-preview"
          gpt-3.5-turbo:
            deploymentName: gpt-35-turbo
          gpt-3.5-turbo-1106:
            deploymentName: gpt-35-turbo-1106
          gpt-4:
            deploymentName: gpt-4
          gpt-4-1106-preview:
            deploymentName: gpt-4-1106-preview
      - group: "my-eastus"
        apiKey: "${EASTUS_API_KEY}"
        instanceName: "actual-eastus-instance-name"
        deploymentName: gpt-4-turbo
        version: "2024-02-15-preview"
        baseURL: "https://gateway.ai.cloudflare.com/v1/cloudflareId/azure/azure-openai/${INSTANCE_NAME}/${DEPLOYMENT_NAME}" # uses env variables
        additionalHeaders:
          X-Custom-Header: value
        models:
          gpt-4-turbo: true

注意: Azure OpenAI endpoint 支持所有 Shared Endpoint Settings,包括 streamRatetitleModeltitleMethodtitlePrompttitlePromptTemplatetitleEndpoint

assistants

键:

KeyTypeDescriptionExample
assistantsBoolean启用或禁用 Azure OpenAI endpoint 的 Assistants。设置为 `true` 时,将激活与此 endpoint 关联的 Assistants。Choose one, either the official OpenAI API or Azure OpenAI API for assistants, not both.

默认值: 未指定

示例:

assistants: true

groups

键:

KeyTypeDescriptionExample
groupsArray按地理位置或用途对模型组进行的配置。`groups` 数组中的每一项都配置了一组特定分组下的模型,通常按地理区域或不同的配置进行划分。

默认值: 未指定

注意: 请参阅上方的示例。

组对象结构

groups 下的每一项都是记录列表的一部分,每一项都包含以下字段:

group

键:

KeyTypeDescriptionExample
groupString模型组的标识符。

必需:

示例:

"group": "my-westus"

apiKey

键:

KeyTypeDescriptionExample
apiKeyString用于访问 Azure OpenAI Service 的 API 密钥。It's highly recommended to use a custom env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

必需:

示例:

apiKey: "${WESTUS_API_KEY}"

instanceName

键:

KeyTypeDescriptionExample
instanceNameStringAzure 实例的名称。**支持两种域名格式**:`.openai.azure.com`(旧版)和 `.cognitiveservices.azure.com`(新版)。您可以指定完整域名(例如 `my-instance.cognitiveservices.azure.com`),也可以仅指定实例名称(例如 `my-instance`),以保持与旧版 `.openai.azure.com` 格式的向后兼容性。It's recommended to use a custom env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

必需:

示例:

# Using just the instance name (legacy format applied)
instanceName: "my-westus"
# OR using the full domain (new format)
instanceName: "my-westus.cognitiveservices.azure.com"

version

键:

KeyTypeDescriptionExample
versionStringAPI 版本It's recommended to use a custom env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

默认值: 未指定

示例:

version: "2023-12-01-preview"

baseURL

键:

KeyTypeDescriptionExample
baseURLStringAzure OpenAI Service 的基础 URL。It's recommended to use a custom env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

默认值: 未指定

示例:

baseURL: "https://prod.example.com"

additionalHeaders

键:

KeyTypeDescriptionExample
additionalHeadersDictionaryAPI 请求的附加标头。所有标头值必须为字符串。It's recommended to use a custom env. variable reference for the values of field, as shown in the example. `api-key` header value is sent on every request.

默认值: 未指定

示例:

additionalHeaders:
  X-Custom-Header: ${YOUR_SECRET_CUSTOM_VARIABLE}

serverless

键:

KeyTypeDescriptionExample
serverlessBoolean指示使用用于 Azure OpenAI 聊天补全的无服务器推理 endpoint。当设置为 `true` 时,指定该组被配置为使用无服务器推理 endpoint 作为 Azure “模型即服务”(Models as a Service) 模型。More info [here](./azure_openai.md#serverless-inference-endpoints)

默认值: 未指定

示例:

serverless: true

addParams

键:

KeyTypeDescriptionExample
addParamsObject/Dictionary向请求添加额外参数。适用于指定特定于 API 的选项。

默认值: 未指定

示例:

addParams:
  safe_prompt: true

dropParams

键:

KeyTypeDescriptionExample
dropParamsArray/List of Strings从请求中移除 [default parameters](#default-parameters)。排除指定的 [default parameters](#default-parameters)。For a list of default parameters sent with every request, see the ["Default Parameters"](#default-parameters) Section below.

默认值: 未指定

示例:

dropParams: ["stop", "user", "frequency_penalty", "presence_penalty"]

models

键:

KeyTypeDescriptionExample
models针对组内各个模型的配置。用于配置每个模型的设置,包括部署名称和版本。Model configurations can adopt the group's deployment name and/or version when configured as a boolean (set to `true`) or an object for detailed settings of either of those fields.

默认值: 未指定

示例:

models:
  gpt-4-vision-preview: 
    deploymentName: "arbitrary-deployment-name"
    version: "2024-02-15-preview"

这篇指南怎么样?