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

Anthropic

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,包括 streamRateheaderstitleModeltitleMethodtitlePrompttitlePromptTemplatetitleEndpoint
  • 要将 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

先决条件

  1. 已启用 Vertex AI API 的 Google Cloud Project
  2. Service Account,并具备以下角色:
    • Vertex AI User (roles/aiplatform.user)
    • 或者 Vertex AI Administrator 以获得完全访问权限
  3. 在您的 Vertex AI Model Garden 中启用的 Claude models
  4. 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

这篇指南怎么样?