Vercel AI Gateway

适用范围

在以下情况使用此页面:

  • 你想在 Moltbot 中使用 Vercel AI Gateway
  • 你需要 API 密钥环境变量或 CLI 认证选项

Vercel AI Gateway 提供一个统一 API,通过单个端点访问数百个模型。

  • 提供商:vercel-ai-gateway
  • 认证:AI_GATEWAY_API_KEY
  • API:与 Anthropic Messages 兼容

快速开始

  1. 设置 API 密钥(推荐:为 Gateway 存储):
moltbot onboard --auth-choice ai-gateway-api-key
  1. 设置默认模型:
{
  agents: {
    defaults: {
      model: { primary: "vercel-ai-gateway/anthropic/claude-opus-4.5" }
    }
  }
}

非交互式示例

moltbot onboard --non-interactive \
  --mode local \
  --auth-choice ai-gateway-api-key \
  --ai-gateway-api-key "$AI_GATEWAY_API_KEY"

环境变量说明

如果 Gateway 作为守护进程(launchd/systemd)运行,请确保 AI_GATEWAY_API_KEY 对该进程可用(例如,在 ~/.moltbot/.env 中或通过 env.shellEnv)。