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

自定义 endpoint 对象结构

custom 数组中的每个 endpoint 都应具有以下结构:

示例

endpoints:
  custom:
    # Example using Mistral AI API
    - name: 'Mistral'
      apiKey: '${YOUR_ENV_VAR_KEY}'
      baseURL: 'https://api.mistral.ai/v1'
      models:
        default: ['mistral-tiny', 'mistral-small', 'mistral-medium', 'mistral-large-latest']
      titleConvo: true
      titleTiming: 'immediate'
      titleModel: 'mistral-tiny'
      modelDisplayLabel: 'Mistral'
      # customParams:
      #   reasoningFormat: reasoning_object
      #   reasoningKey: reasoning_content
      # tokenConfig:
      #   mistral-large-latest:
      #     prompt: 2
      #     completion: 6
      #     context: 128000
      # addParams:
      #   safe_prompt: true # Mistral specific value for moderating messages
      # NOTE: For Mistral, it is necessary to drop the following parameters or you will encounter a 422 Error:
      dropParams: ['stop', 'user', 'frequency_penalty', 'presence_penalty']
 
    # Example using the native Anthropic Messages API
    - name: 'Claude-Compatible'
      provider: 'anthropic'
      apiKey: '${ANTHROPIC_API_KEY}'
      baseURL: 'https://api.anthropic.com'
      headers:
        anthropic-version: '2023-06-01'
      models:
        default: ['claude-sonnet-4-5', 'claude-opus-4-5']
        fetch: false
      titleConvo: true
      titleModel: 'claude-sonnet-4-5'
      modelDisplayLabel: 'Claude (Compatible)'

name

键:

KeyTypeDescriptionExample
nameString该 endpoint 的唯一名称。Will be used as the "title" in the Endpoints Selector

必需

示例:

name: 'Mistral'

apiKey

键:

KeyTypeDescriptionExample
apiKeyString (apiKey | "user_provided")该服务的 API 密钥。可以引用环境变量,或允许用户提供该值。It's highly recommended to use the env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

必需

示例:

apiKey: '${MISTRAL_API_KEY}'

apiKey: 'your_api_key'

apiKey: 'user_provided'

baseURL

键:

KeyTypeDescriptionExample
baseURLString (baseURL | "user_provided")API 的基础 URL。可以引用环境变量,或允许用户提供该值。It's highly recommended to use the env. variable reference for this field, i.e. `${YOUR_VARIABLE}`

必需

示例:

baseURL: 'https://api.mistral.ai/v1'

baseURL: '${MISTRAL_BASE_URL}'

baseURL: 'user_provided'

注意:

  • 如果您设置的 baseURL 是完整的补全 endpoint,您可以将 directEndpoint 字段设置为 true 以直接使用它。
    • 这是必要的,因为该应用默认会在 baseURL 后追加 "/chat/completions" 或 "/completion"。
  • 当使用 provider: anthropic 时,请将 baseURL 设置为 Anthropic SDK 应调用的 API 根路径,例如 https://api.anthropic.com 或您的网关根路径。LibreChat 会针对该提供商使用原生的 Anthropic /v1/messages 路径。

provider

键:

KeyTypeDescriptionExample
providerString通过原生提供商客户端而非默认的 OpenAI 兼容客户端来路由自定义 endpoint。Currently supports `anthropic`.

默认值: 省略,这将使用兼容 OpenAI 的自定义 endpoint 路径。

支持的值:

  • "anthropic" - 使用原生的 Anthropic /v1/messages 客户端,并结合此 endpoint 的 baseURLapiKeyheadersaddParamsdropParamscustomParams.paramDefinitions

示例:

endpoints:
  custom:
    - name: 'Claude-Compatible'
      provider: 'anthropic'
      apiKey: '${ANTHROPIC_API_KEY}'
      baseURL: 'https://api.anthropic.com'
      headers:
        anthropic-version: '2023-06-01'
      models:
        default:
          - 'claude-sonnet-4-5'
          - 'claude-opus-4-5'
        fetch: false
      titleConvo: true
      titleModel: 'claude-sonnet-4-5'
      modelDisplayLabel: 'Claude (Compatible)'

注意:

  • 对于 Anthropic 官方或支持原生 Messages API 的 Anthropic 兼容网关,请使用 provider: anthropic
  • models.default 下显式列出模型;OpenAI 风格的 models.fetch 不适用于原生的 Anthropic 自定义 endpoint。
  • 除非您明确设置了不同的 customParams.defaultParamsEndpoint,否则该提供商将默认使用 Anthropic UI 参数。
  • 没有 provider 的 endpoint 保持与 OpenAI 兼容的行为。

iconURL

键:

KeyTypeDescriptionExample
iconURLString用于端点图标的图片 URL、公共资源路径或内置端点图标键。

默认值: ""

示例:

iconURL: https://github.com/danny-avila/LibreChat/raw/main/docs/assets/LibreChat.svg

或者复用内置的 endpoint 图标:

iconURL: openAI

注意:

  • 不要将自定义 endpoint 的 name 设置为内置 endpoint 的名称,仅仅为了复用图标。自定义 endpoint 名称必须是唯一的,且不应使用默认的 endpoint 值,例如:
    • "openAI" | "azureOpenAI" | "google" | "anthropic" | "assistants" | "azureAssistants" | "agents" | "bedrock"
  • 若要使用项目内置的 endpoint 图标,请保持自定义 endpoint 的 name 唯一,并将 iconURL 设置为内置 endpoint 键之一。
    • "openAI" | "azureOpenAI" | "google" | "anthropic" | "assistants" | "azureAssistants" | "agents" | "bedrock"
  • 要使用自定义图像,请将 iconURL 设置为图像 URL 或 LibreChat 提供的路径,例如 /assets/my-icon.svg
  • 此外还有“已知 endpoint”(不区分大小写),它们提供了相应的图标。如果你的 endpoint name 与以下名称匹配,则应省略此字段:
    • Anyscale
    • APIpie
    • Cohere
    • Deepseek
    • Fireworks
    • groq
    • Helicone
    • Huggingface
    • Mistral
    • MLX
    • 月之暗面
    • ollama
    • OpenRouter
    • Perplexity
    • 通义千问
    • ShuttleAI
    • together.ai
    • 统一
    • xai

models

键:

KeyTypeDescriptionExample
modelsObject模型配置。

必需

属性:

default

键:

KeyTypeDescriptionExample
defaultArray of Strings一个字符串数组,用于指定要使用的默认模型。If fetching models fails, these defaults are used as a fallback.

必需

示例:

default:
  - 'mistral-tiny'
  - 'mistral-small'
  - 'mistral-medium'

fetch

键:

KeyTypeDescriptionExample
fetchBoolean当设置为 `true` 时,尝试从 API 获取模型列表。May cause slowdowns during initial use of the app if the response is delayed. Defaults to `false`.

默认值: false

示例:

fetch: true

userIdQuery

键:

KeyTypeDescriptionExample
userIdQueryBoolean当设置为 `true` 时,会将 LibreChat 用户 ID 作为查询参数添加到 API 模型请求中。

默认值: false

示例:

userIdQuery: true

titleConvo

键:

KeyTypeDescriptionExample
titleConvoBoolean当设置为 `true` 时,启用对话标题生成。

默认值: false

示例:

titleConvo: true

titleTiming

键:

KeyTypeDescriptionExample
titleTimingString控制何时生成对话标题。有效值为 "immediate" 或 "final"。Defaults to "immediate".

默认值: "immediate"

可用值:

  • "immediate" - 在请求开始时立即生成标题,与模型响应并行,并使用用户的首条消息。
  • "final" - 将标题生成推迟到完整响应完成之后。这保留了旧有的行为。

示例:

titleTiming: 'final'

titleMethod

键:

KeyTypeDescriptionExample
titleMethodString控制用于生成对话标题的方法。Valid values: "completion" (default), "structured", "functions" (legacy alias for "structured")

默认值: "completion"

可用方法:

  • "completion" - 使用不带工具/函数的标准 completion API。兼容大多数 LLM。
  • "structured" - 使用结构化输出进行标题生成。需要提供商/模型支持。
  • "functions" - "structured" 的旧版别名。功能完全相同。

示例:

titleMethod: 'completion'

titleModel

键:

KeyTypeDescriptionExample
titleModelString指定用于生成标题的模型。Defaults to "gpt-3.5-turbo" if omitted. May cause issues if "gpt-3.5-turbo" is not available. You can also dynamically use the current conversation model by setting it to "current_model".

默认值: "gpt-3.5-turbo"

示例:

titleModel: 'mistral-tiny'
titleModel: 'current_model'

titlePrompt

键:

KeyTypeDescriptionExample
titlePromptString用于生成标题的自定义提示词。必须包含 {convo} 占位符。Allows full control over how titles are generated.

默认:

Analyze this conversation and provide:
1. The detected language of the conversation
2. A concise title in the detected language (5 words or less, no punctuation or quotation)

{convo}

注意:

  • 必须始终包含 {convo} 占位符
  • {convo} 占位符将被替换为格式化后的对话

示例:

titlePrompt: "Create a brief, descriptive title for the following conversation:\n\n{convo}\n\nTitle:"

titlePromptTemplate

键:

KeyTypeDescriptionExample
titlePromptTemplateString用于格式化对话内容并替换 titlePrompt 中 {convo} 的模板。Must include {input} and {output} placeholders.

默认值: "User: {input}\nAI: {output}"

注意:

  • 必须包含 {input}{output} 占位符
  • 控制对话在插入 titlePrompt 时的格式化方式

示例:

titlePromptTemplate: "Human: {input}\n\nAssistant: {output}"

titleEndpoint

键:

KeyTypeDescriptionExample
titleEndpointString指定用于生成标题的替代 endpoint。Allows using a different model/endpoint for titles.

默认: 使用当前的自定义 endpoint

接受的值:

  • openAI
  • azureOpenAI
  • google
  • anthropic
  • bedrock
  • 另一个自定义 endpoint 名称

示例:

# Use a different custom endpoint for titles
endpoints:
  custom:
    - name: 'my-chat-endpoint'
      apiKey: '${CHAT_API_KEY}'
      baseURL: 'https://api.example.com/v1/chat'
      models:
        default: ['gpt-4']
      titleEndpoint: 'my-title-endpoint'
 
    - name: 'my-title-endpoint'
      apiKey: '${TITLE_API_KEY}'
      baseURL: 'https://api.example.com/v1/title'
      models:
        default: ['gpt-3.5-turbo']

modelDisplayLabel

键:

KeyTypeDescriptionExample
modelDisplayLabelString在消息中当前 AI 模型图标旁边显示的标签。The display order is: 1. Custom name set via preset (if available), 2. Label derived from the model name (if applicable), 3. This value is used if the above are not specified. Defaults to "AI".

默认值: "AI"

示例:

modelDisplayLabel: 'Mistral'

addParams

键:

KeyTypeDescriptionExample
addParamsObject/Dictionary向请求添加额外参数。值可以是字符串、数字、布尔值、数组或嵌套对象。支持使用 `web_search: true` 在请求中启用网络搜索。Adds/Overrides parameters. Useful for specifying API-specific options.

示例:

addParams:
  safe_prompt: true
  max_tokens: 2048

注意:

  • addParams 字段允许您包含不属于默认负载(请参阅 "Default Parameters" 部分)的额外参数。这对于 API 特定的选项特别有用。

dropParams

键:

KeyTypeDescriptionExample
dropParamsArray/List of Strings从请求中移除默认参数。Excludes specified default parameters. Useful for APIs that do not accept or recognize certain parameters.

示例:

dropParams:
  - 'stop'
  - 'user'
  - 'frequency_penalty'
  - 'presence_penalty'

注意:

  • dropParams 字段允许您移除随每个请求发送的 "Default Parameters"。当使用不接受或无法识别某些参数的 API 时,此功能非常有用。

customParams

键:

KeyTypeDescriptionExample
customParamsObject/Dictionary定义不属于提供商请求主体的自定义 endpoint 行为和设置元数据。Used for endpoint-specific configuration such as reasoning parameter shape.

子键:

KeyTypeDescriptionExample
defaultParamsEndpointString用于请求参数元数据的 endpoint 默认值。默认为 `custom`。当设置 `provider: anthropic` 且省略此字段时,LibreChat 将使用 Anthropic 参数集。defaultParamsEndpoint: custom
reasoningFormatString控制如何将推理参数发送至兼容 OpenAI 的自定义 endpoint。有效值:`reasoning_effort`、`reasoning_object`、`disabled`。reasoningFormat: reasoning_object
reasoningKeyString控制读取哪个响应键以获取提供商的推理内容。有效值为 `reasoning` 或 `reasoning_content`。reasoningKey: reasoning_content
paramDefinitionsArray/List此 endpoint 的自定义设置定义。See default parameter definitions.

推理格式:

  • reasoning_effort - 发送旧版 reasoning_effort 参数。
  • reasoning_object - 为遵循较新 OpenAI 兼容格式的提供商发送一个 reasoning 对象,例如 { effort, summary }
  • disabled - 即使在用户或 Model Specs 选择推理时,也会抑制推理参数。

Anthropic 提供商说明:

当自定义 endpoint 需要使用原生的 Anthropic Messages API 时,请使用 provider: anthropic。仅当你仍然需要兼容 OpenAI 的自定义 endpoint 路径,但希望使用 Anthropic 风格的参数元数据和请求适配时,才在不使用 provider 的情况下使用 customParams.defaultParamsEndpoint: anthropic

示例:

customParams:
  reasoningFormat: reasoning_object
  reasoningKey: reasoning_content

tokenConfig

键:

KeyTypeDescriptionExample
tokenConfigObject/Dictionary为该自定义 endpoint 定义特定模型的上下文窗口以及每百万 token 的费率。Used by context usage, visible cost breakdowns, balance transactions, and multi-endpoint agent billing.

每个键都是一个模型名称。每个模型条目支持:

KeyTypeDescriptionExample
promptNumber每百万 token 的提示词/输入 token 费率。Required
completionNumber每百万 token 的补全/输出 token 费率。Required
contextNumber该模型的最大上下文窗口。Required
cacheReadNumber每百万 token 的缓存输入读取速率。Optional
cacheWriteNumber每百万 token 的缓存输入写入速率。Optional

示例:

tokenConfig:
  gpt-4o-mini:
    prompt: 0.15
    completion: 0.6
    context: 128000
    cacheRead: 0.075
    cacheWrite: 0.15

注意:

  • 费率以每百万 token 的美元 (USD) 金额表示,在应用任何 interface.currency 转换以供显示之前。
  • 模型名称必须与通过自定义 endpoint 发送的模型值相匹配。
  • 对于使用多个 endpoint 的 Agent,在记录使用量和成本时,会使用匹配的 endpoint/model token 配置。

headers

键:

KeyTypeDescriptionExample
headersObject/Dictionary为请求添加额外的请求头。所有请求头的值必须为字符串。支持使用 `{{LIBRECHAT_USER_*}}` 进行动态用户字段替换,使用 `{{LIBRECHAT_BODY_*}}` 进行请求体占位符替换,以及使用 `${ENV_VAR}` 引用环境变量。The `headers` object specifies custom headers for requests. Useful for authentication and setting content types.

示例:

headers:
  x-api-key: '${ENVIRONMENT_VARIABLE}'
  Content-Type: 'application/json'
  X-User-ID: '{{LIBRECHAT_USER_ID}}'
  X-User-Email: '{{LIBRECHAT_USER_EMAIL}}'

注意: 支持动态环境变量值,格式为:"${VARIABLE_NAME}"

当使用 models.fetch: true 时,这些请求头也会被解析并转发到针对管理员控制的 base URL 的模型列表请求中。配置的 Authorization 请求头优先级高于 endpoint 的 apiKey 回退值,这对于返回按用户划分模型列表的具备身份验证功能的代理非常有用。如果配置了 baseURL: "user_provided",LibreChat 不会将配置的请求头模板转发到用户提供的目标地址。对于 provider: anthropic,请求头将通过原生的 Anthropic 客户端转发,而不是通过兼容 OpenAI 的客户端。

可用的用户字段占位符:

占位符用户字段类型描述
{{LIBRECHAT_USER_ID}}idString用户的唯一标识符
{{LIBRECHAT_USER_NAME}}nameString用户的显示名称
{{LIBRECHAT_USER_USERNAME}}usernameString用户的用户名
{{LIBRECHAT_USER_EMAIL}}emailString用户的电子邮件地址
{{LIBRECHAT_USER_PROVIDER}}providerString身份验证提供商(例如:"email", "google", "github")
{{LIBRECHAT_USER_ROLE}}roleString用户的角色(例如:"user", "admin")
{{LIBRECHAT_USER_GOOGLEID}}googleIdStringGoogle 账户 ID
{{LIBRECHAT_USER_FACEBOOKID}}facebookIdStringFacebook 账户 ID
{{LIBRECHAT_USER_OPENIDID}}openidIdStringOpenID 账户 ID
{{LIBRECHAT_USER_SAMLID}}samlIdStringSAML 账户 ID
{{LIBRECHAT_USER_LDAPID}}ldapIdStringLDAP 账户 ID
{{LIBRECHAT_USER_GITHUBID}}githubIdStringGitHub 账户 ID
{{LIBRECHAT_USER_DISCORDID}}discordIdStringDiscord 账户 ID
{{LIBRECHAT_USER_APPLEID}}appleIdStringApple 账户 ID
{{LIBRECHAT_USER_EMAILVERIFIED}}emailVerifiedBoolean → String电子邮件验证状态("true" 或 "false")
{{LIBRECHAT_USER_TWOFACTORENABLED}}twoFactorEnabledBoolean → String双重身份验证 (2FA) 状态("true" 或 "false")
{{LIBRECHAT_USER_TERMSACCEPTED}}termsAcceptedBoolean → String条款接受状态("true" 或 "false")

可用的请求体占位符:

占位符正文字段类型描述
{{LIBRECHAT_BODY_CONVERSATIONID}}conversationIdString当前对话标识符
{{LIBRECHAT_BODY_PARENTMESSAGEID}}parentMessageIdString父消息标识符
{{LIBRECHAT_BODY_MESSAGEID}}messageIdString当前消息标识符

使用请求体占位符的示例:

headers:
  X-Conversation-ID: '{{LIBRECHAT_BODY_CONVERSATIONID}}'
  X-Parent-Message-ID: '{{LIBRECHAT_BODY_PARENTMESSAGEID}}'
  X-Message-ID: '{{LIBRECHAT_BODY_MESSAGEID}}'

directEndpoint

键:

KeyTypeDescriptionExample
directEndpointBoolean当设置为 `true` 时,将配置的 `baseURL` 视为要使用的补全 endpoint

默认值: false

示例:

directEndpoint: true

titleMessageRole

  • 选项"system" | "user" | "assistant"

键:

KeyTypeDescriptionExample
titleMessageRoleString指定用于标题生成的消息负载中的 role 值。必须是以下值之一:`"system"`、`"user"`、`"assistant"`。Defaults to "system" if omitted. May cause issues if "system" is not a valid value, which is sometimes the case for single message payloads, as it is for title generation.

默认值: "system"

示例:

titleMessageRole: 'user'

这篇指南怎么样?