Anthropic
- 在 https://platform.claude.com/ 创建一个账户
- 前往 https://platform.claude.com/settings/keys 并获取您的 api key
- 您需要将以下环境变量设置为您的密钥,或者将其设置为
user_provided以便用户提供他们自己的密钥。
ANTHROPIC_API_KEY=user_provided- 您可以通过
ANTHROPIC_MODELS来决定您想要使用的模型。
ANTHROPIC_MODELS=claude-fable-5,claude-opus-4-8,claude-opus-4-7,claude-sonnet-4-6,claude-opus-4-6,claude-opus-4-20250514,claude-3-7-sonnet-20250219,claude-3-5-sonnet-20241022,claude-3-5-haiku-20241022注意:
- Claude Fable 5 已包含在 LibreChat 的默认 Anthropic 模型目录中。Fable/Mythos 类模型在 LibreChat 中使用现代 Anthropic 配置:1M 上下文、128K 最大输出、自适应思维(adaptive thinking)、提示词缓存(prompt caching),并支持
thinkingDisplay以实现摘要或省略推理输出。 - Anthropic endpoint 支持通过
librechat.yaml配置文件使用所有 Shared Endpoint Settings,包括streamRate、headers、titleModel、titleMethod、titlePrompt、titlePromptTemplate和titleEndpoint。 - 要将 Anthropic 或兼容 Anthropic 的网关配置为单独的自定义 endpoint,请使用
provider: "anthropic"。
Vertex AI
LibreChat 支持通过 Google Cloud Vertex AI 运行 Anthropic Claude 模型。如果您有以下需求,这将非常有用:
- 已经拥有 Google Cloud 基础设施
- 想要使用您现有的 GCP 账单和凭据
- 需要符合区域数据驻留要求
快速设置(环境变量)
设置以下环境变量以通过 Vertex AI 启用 Anthropic:
# Enable Vertex AI mode for Anthropic
ANTHROPIC_USE_VERTEX=true
# Vertex AI region (optional, defaults to 'us-east5')
# Available regions: global, us-east5, us-central1, europe-west1, europe-west4, asia-southeast1
ANTHROPIC_VERTEX_REGION=global
# Path to Google service account key file (optional)
# If not specified, uses default path: api/data/auth.json
GOOGLE_SERVICE_KEY_FILE=/path/to/service-account.json先决条件
- 已启用 Vertex AI API 的 Google Cloud Project
- Service Account,并具备以下角色:
Vertex AI User(roles/aiplatform.user)- 或者
Vertex AI Administrator以获得完全访问权限
- 在您的 Vertex AI Model Garden 中启用的 Claude models
- Service Account Key (JSON 文件),已下载并可供 LibreChat 访问
高级配置
对于模型名称映射和高级设置(类似于 Azure OpenAI 配置),请使用 librechat.yaml 文件:
endpoints:
anthropic:
vertex:
region: us-east5
models:
claude-opus-4.5:
deploymentName: claude-opus-4-5@20251101
claude-sonnet-4:
deploymentName: claude-sonnet-4-20250514
claude-3.5-haiku:
deploymentName: claude-3-5-haiku@20241022有关详细的 YAML 配置选项,请参阅 Anthropic Vertex AI Configuration。
这篇指南怎么样?