自定义 endpoint 对象结构
custom 数组中的每个 endpoint 都应具有以下结构:
示例
name
键:
| Key | Type | Description | Example |
|---|---|---|---|
| name | String | 该 endpoint 的唯一名称。 | Will be used as the "title" in the Endpoints Selector |
必需
示例:
apiKey
键:
| Key | Type | Description | Example |
|---|---|---|---|
| apiKey | String (apiKey | "user_provided") | 该服务的 API 密钥。可以引用环境变量,或允许用户提供该值。 | It's highly recommended to use the env. variable reference for this field, i.e. `${YOUR_VARIABLE}` |
必需
示例:
或
或
baseURL
键:
| Key | Type | Description | Example |
|---|---|---|---|
| baseURL | String (baseURL | "user_provided") | API 的基础 URL。可以引用环境变量,或允许用户提供该值。 | It's highly recommended to use the env. variable reference for this field, i.e. `${YOUR_VARIABLE}` |
必需
示例:
或
或
注意:
- 如果您设置的
baseURL是完整的补全 endpoint,您可以将 directEndpoint 字段设置为true以直接使用它。- 这是必要的,因为该应用默认会在
baseURL后追加 "/chat/completions" 或 "/completion"。
- 这是必要的,因为该应用默认会在
- 当使用
provider: anthropic时,请将baseURL设置为 Anthropic SDK 应调用的 API 根路径,例如https://api.anthropic.com或您的网关根路径。LibreChat 会针对该提供商使用原生的 Anthropic/v1/messages路径。
provider
键:
| Key | Type | Description | Example |
|---|---|---|---|
| provider | String | 通过原生提供商客户端而非默认的 OpenAI 兼容客户端来路由自定义 endpoint。 | Currently supports `anthropic`. |
默认值: 省略,这将使用兼容 OpenAI 的自定义 endpoint 路径。
支持的值:
"anthropic"- 使用原生的 Anthropic/v1/messages客户端,并结合此 endpoint 的baseURL、apiKey、headers、addParams、dropParams和customParams.paramDefinitions。
示例:
注意:
- 对于 Anthropic 官方或支持原生 Messages API 的 Anthropic 兼容网关,请使用
provider: anthropic。 - 在
models.default下显式列出模型;OpenAI 风格的models.fetch不适用于原生的 Anthropic 自定义 endpoint。 - 除非您明确设置了不同的
customParams.defaultParamsEndpoint,否则该提供商将默认使用 Anthropic UI 参数。 - 没有
provider的 endpoint 保持与 OpenAI 兼容的行为。
iconURL
键:
| Key | Type | Description | Example |
|---|---|---|---|
| iconURL | String | 用于端点图标的图片 URL、公共资源路径或内置端点图标键。 |
默认值: ""
示例:
或者复用内置的 endpoint 图标:
注意:
- 不要将自定义 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
键:
| Key | Type | Description | Example |
|---|---|---|---|
| models | Object | 模型配置。 |
必需
属性:
default
键:
| Key | Type | Description | Example |
|---|---|---|---|
| default | Array of Strings | 一个字符串数组,用于指定要使用的默认模型。 | If fetching models fails, these defaults are used as a fallback. |
必需
示例:
fetch
键:
| Key | Type | Description | Example |
|---|---|---|---|
| fetch | Boolean | 当设置为 `true` 时,尝试从 API 获取模型列表。 | May cause slowdowns during initial use of the app if the response is delayed. Defaults to `false`. |
默认值: false
示例:
userIdQuery
键:
| Key | Type | Description | Example |
|---|---|---|---|
| userIdQuery | Boolean | 当设置为 `true` 时,会将 LibreChat 用户 ID 作为查询参数添加到 API 模型请求中。 |
默认值: false
示例:
titleConvo
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleConvo | Boolean | 当设置为 `true` 时,启用对话标题生成。 |
默认值: false
示例:
titleTiming
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleTiming | String | 控制何时生成对话标题。有效值为 "immediate" 或 "final"。 | Defaults to "immediate". |
默认值: "immediate"
可用值:
"immediate"- 在请求开始时立即生成标题,与模型响应并行,并使用用户的首条消息。"final"- 将标题生成推迟到完整响应完成之后。这保留了旧有的行为。
示例:
titleMethod
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleMethod | String | 控制用于生成对话标题的方法。 | Valid values: "completion" (default), "structured", "functions" (legacy alias for "structured") |
默认值: "completion"
可用方法:
"completion"- 使用不带工具/函数的标准 completion API。兼容大多数 LLM。"structured"- 使用结构化输出进行标题生成。需要提供商/模型支持。"functions"- "structured" 的旧版别名。功能完全相同。
示例:
titleModel
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleModel | String | 指定用于生成标题的模型。 | 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"
示例:
titlePrompt
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titlePrompt | String | 用于生成标题的自定义提示词。必须包含 {convo} 占位符。 | Allows full control over how titles are generated. |
默认:
注意:
- 必须始终包含
{convo}占位符 {convo}占位符将被替换为格式化后的对话
示例:
titlePromptTemplate
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titlePromptTemplate | String | 用于格式化对话内容并替换 titlePrompt 中 {convo} 的模板。 | Must include {input} and {output} placeholders. |
默认值: "User: {input}\nAI: {output}"
注意:
- 必须包含
{input}和{output}占位符 - 控制对话在插入
titlePrompt时的格式化方式
示例:
titleEndpoint
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleEndpoint | String | 指定用于生成标题的替代 endpoint。 | Allows using a different model/endpoint for titles. |
默认: 使用当前的自定义 endpoint
接受的值:
openAIazureOpenAIgoogleanthropicbedrock- 另一个自定义 endpoint 名称
示例:
modelDisplayLabel
键:
| Key | Type | Description | Example |
|---|---|---|---|
| modelDisplayLabel | String | 在消息中当前 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"
示例:
addParams
键:
| Key | Type | Description | Example |
|---|---|---|---|
| addParams | Object/Dictionary | 向请求添加额外参数。值可以是字符串、数字、布尔值、数组或嵌套对象。支持使用 `web_search: true` 在请求中启用网络搜索。 | Adds/Overrides parameters. Useful for specifying API-specific options. |
示例:
注意:
addParams字段允许您包含不属于默认负载(请参阅 "Default Parameters" 部分)的额外参数。这对于 API 特定的选项特别有用。
dropParams
键:
| Key | Type | Description | Example |
|---|---|---|---|
| dropParams | Array/List of Strings | 从请求中移除默认参数。 | Excludes specified default parameters. Useful for APIs that do not accept or recognize certain parameters. |
示例:
注意:
dropParams字段允许您移除随每个请求发送的 "Default Parameters"。当使用不接受或无法识别某些参数的 API 时,此功能非常有用。
customParams
键:
| Key | Type | Description | Example |
|---|---|---|---|
| customParams | Object/Dictionary | 定义不属于提供商请求主体的自定义 endpoint 行为和设置元数据。 | Used for endpoint-specific configuration such as reasoning parameter shape. |
子键:
| Key | Type | Description | Example |
|---|---|---|---|
| defaultParamsEndpoint | String | 用于请求参数元数据的 endpoint 默认值。默认为 `custom`。当设置 `provider: anthropic` 且省略此字段时,LibreChat 将使用 Anthropic 参数集。 | defaultParamsEndpoint: custom |
| reasoningFormat | String | 控制如何将推理参数发送至兼容 OpenAI 的自定义 endpoint。有效值:`reasoning_effort`、`reasoning_object`、`disabled`。 | reasoningFormat: reasoning_object |
| reasoningKey | String | 控制读取哪个响应键以获取提供商的推理内容。有效值为 `reasoning` 或 `reasoning_content`。 | reasoningKey: reasoning_content |
| paramDefinitions | Array/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。
示例:
tokenConfig
键:
| Key | Type | Description | Example |
|---|---|---|---|
| tokenConfig | Object/Dictionary | 为该自定义 endpoint 定义特定模型的上下文窗口以及每百万 token 的费率。 | Used by context usage, visible cost breakdowns, balance transactions, and multi-endpoint agent billing. |
每个键都是一个模型名称。每个模型条目支持:
| Key | Type | Description | Example |
|---|---|---|---|
| prompt | Number | 每百万 token 的提示词/输入 token 费率。 | Required |
| completion | Number | 每百万 token 的补全/输出 token 费率。 | Required |
| context | Number | 该模型的最大上下文窗口。 | Required |
| cacheRead | Number | 每百万 token 的缓存输入读取速率。 | Optional |
| cacheWrite | Number | 每百万 token 的缓存输入写入速率。 | Optional |
示例:
注意:
- 费率以每百万 token 的美元 (USD) 金额表示,在应用任何
interface.currency转换以供显示之前。 - 模型名称必须与通过自定义 endpoint 发送的模型值相匹配。
- 对于使用多个 endpoint 的 Agent,在记录使用量和成本时,会使用匹配的 endpoint/model token 配置。
headers
键:
| Key | Type | Description | Example |
|---|---|---|---|
| headers | Object/Dictionary | 为请求添加额外的请求头。所有请求头的值必须为字符串。支持使用 `{{LIBRECHAT_USER_*}}` 进行动态用户字段替换,使用 `{{LIBRECHAT_BODY_*}}` 进行请求体占位符替换,以及使用 `${ENV_VAR}` 引用环境变量。 | The `headers` object specifies custom headers for requests. Useful for authentication and setting content types. |
示例:
注意: 支持动态环境变量值,格式为:"${VARIABLE_NAME}"。
当使用 models.fetch: true 时,这些请求头也会被解析并转发到针对管理员控制的 base URL 的模型列表请求中。配置的 Authorization 请求头优先级高于 endpoint 的 apiKey 回退值,这对于返回按用户划分模型列表的具备身份验证功能的代理非常有用。如果配置了 baseURL: "user_provided",LibreChat 不会将配置的请求头模板转发到用户提供的目标地址。对于 provider: anthropic,请求头将通过原生的 Anthropic 客户端转发,而不是通过兼容 OpenAI 的客户端。
可用的用户字段占位符:
| 占位符 | 用户字段 | 类型 | 描述 |
|---|---|---|---|
{{LIBRECHAT_USER_ID}} | id | String | 用户的唯一标识符 |
{{LIBRECHAT_USER_NAME}} | name | String | 用户的显示名称 |
{{LIBRECHAT_USER_USERNAME}} | username | String | 用户的用户名 |
{{LIBRECHAT_USER_EMAIL}} | email | String | 用户的电子邮件地址 |
{{LIBRECHAT_USER_PROVIDER}} | provider | String | 身份验证提供商(例如:"email", "google", "github") |
{{LIBRECHAT_USER_ROLE}} | role | String | 用户的角色(例如:"user", "admin") |
{{LIBRECHAT_USER_GOOGLEID}} | googleId | String | Google 账户 ID |
{{LIBRECHAT_USER_FACEBOOKID}} | facebookId | String | Facebook 账户 ID |
{{LIBRECHAT_USER_OPENIDID}} | openidId | String | OpenID 账户 ID |
{{LIBRECHAT_USER_SAMLID}} | samlId | String | SAML 账户 ID |
{{LIBRECHAT_USER_LDAPID}} | ldapId | String | LDAP 账户 ID |
{{LIBRECHAT_USER_GITHUBID}} | githubId | String | GitHub 账户 ID |
{{LIBRECHAT_USER_DISCORDID}} | discordId | String | Discord 账户 ID |
{{LIBRECHAT_USER_APPLEID}} | appleId | String | Apple 账户 ID |
{{LIBRECHAT_USER_EMAILVERIFIED}} | emailVerified | Boolean → String | 电子邮件验证状态("true" 或 "false") |
{{LIBRECHAT_USER_TWOFACTORENABLED}} | twoFactorEnabled | Boolean → String | 双重身份验证 (2FA) 状态("true" 或 "false") |
{{LIBRECHAT_USER_TERMSACCEPTED}} | termsAccepted | Boolean → String | 条款接受状态("true" 或 "false") |
可用的请求体占位符:
| 占位符 | 正文字段 | 类型 | 描述 |
|---|---|---|---|
{{LIBRECHAT_BODY_CONVERSATIONID}} | conversationId | String | 当前对话标识符 |
{{LIBRECHAT_BODY_PARENTMESSAGEID}} | parentMessageId | String | 父消息标识符 |
{{LIBRECHAT_BODY_MESSAGEID}} | messageId | String | 当前消息标识符 |
使用请求体占位符的示例:
directEndpoint
键:
| Key | Type | Description | Example |
|---|---|---|---|
| directEndpoint | Boolean | 当设置为 `true` 时,将配置的 `baseURL` 视为要使用的补全 endpoint |
默认值: false
示例:
titleMessageRole
- 选项:
"system"|"user"|"assistant"
键:
| Key | Type | Description | Example |
|---|---|---|---|
| titleMessageRole | String | 指定用于标题生成的消息负载中的 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"
示例:
这篇指南怎么样?