# Vercel AI 网关

> Vercel AI Gateway 网关设置（身份验证 + 模型选择）

- 网址：https://funcoding.ai/agents/openclaw/providers/vercel-ai-gateway/
- 来源：OpenClaw 官方文档原文（中文），MIT 许可，同步于 2026-10-11
- 官方原文：https://docs.openclaw.ai/zh-CN/providers/vercel-ai-gateway

---
[Vercel AI Gateway](https://vercel.com/ai-gateway) 提供统一 API，可通过单个端点
访问数百种模型。

| 属性          | 值                                     |
| ------------- | -------------------------------------- |
| 提供商        | `vercel-ai-gateway`                    |
| 软件包        | `@openclaw/vercel-ai-gateway-provider` |
| 身份验证      | `AI_GATEWAY_API_KEY`                   |
| API           | 兼容 Anthropic Messages                |
| 基础 URL      | `https://ai-gateway.vercel.sh`         |
| 模型目录      | 通过 `/v1/models` 自动发现       |

<div class="callout callout-tip">

OpenClaw 会自动发现 Gateway 网关的 `/v1/models` 目录，因此
`/models vercel-ai-gateway` 聊天命令和
`openclaw models list --provider vercel-ai-gateway` 都会包含当前的模型引用，
例如 `vercel-ai-gateway/openai/gpt-5.5` 和
`vercel-ai-gateway/moonshotai/kimi-k2.6`。

</div>

## 入门指南

**安装插件**

```bash
openclaw plugins install @openclaw/vercel-ai-gateway-provider
```

**设置 API 密钥**

```bash
openclaw onboard --auth-choice ai-gateway-api-key
```

**设置默认模型**

```json5
{
  agents: {
    defaults: {
      model: { primary: "vercel-ai-gateway/anthropic/claude-opus-4.6" },
    },
  },
}
```

**验证模型是否可用**

```bash
openclaw models list --provider vercel-ai-gateway
```

## 非交互式示例

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

## 模型 ID 简写

OpenClaw 会在运行时规范化 Claude 简写模型引用：

| 简写输入                            | 规范化模型引用                                |
| ----------------------------------- | --------------------------------------------- |
| `vercel-ai-gateway/claude-opus-4.6` | `vercel-ai-gateway/anthropic/claude-opus-4.6` |
| `vercel-ai-gateway/opus-4.6`        | `vercel-ai-gateway/anthropic/claude-opus-4-6` |

<div class="callout callout-tip">

配置中可以使用任一形式；OpenClaw 会自动解析规范的
`anthropic/...` 引用。

</div>

## 高级配置

<details>
<summary>守护进程的环境变量</summary>

如果 OpenClaw Gateway 网关以守护进程（launchd/systemd）运行，请确保
该进程可以使用 `AI_GATEWAY_API_KEY`。

<div class="callout callout-warning">

仅在交互式 shell 中导出的密钥对 launchd/systemd 守护进程不可见，
除非显式导入该环境。请在 `~/.openclaw/.env` 中或通过
`env.shellEnv` 设置密钥，以确保 Gateway 网关进程可以读取它。

</div>

</details>

<details>
<summary>提供商路由</summary>

Vercel AI Gateway 会根据模型引用前缀中指定的上游提供商路由每个请求。
例如，`vercel-ai-gateway/anthropic/claude-opus-4.6` 通过 Anthropic 路由，
`vercel-ai-gateway/openai/gpt-5.5` 通过 OpenAI 路由，而
`vercel-ai-gateway/moonshotai/kimi-k2.6` 通过 MoonshotAI 路由。
一个 `AI_GATEWAY_API_KEY` 即可向所有上游提供商进行身份验证。

</details>

<details>
<summary>思考级别</summary>

当 OpenClaw 能够识别上游模型前缀时，`/think` 选项会遵循该前缀。
`vercel-ai-gateway/anthropic/...` 使用 Claude 思考配置，包括 Claude 4.6 模型的自适应默认值。
可信的 `vercel-ai-gateway/openai/...` 引用（`gpt-5.2` 及更新版本，
以及低至 `gpt-5.1-codex` 的 Codex 变体）会公开
`/think xhigh`。其他带命名空间的引用会保留标准推理级别，
除非其目录元数据声明了更多级别。

</details>

## 相关内容

- [模型选择](https://funcoding.ai/agents/openclaw/concepts/model-providers/)：选择提供商、模型引用和故障转移行为。
- [故障排查](https://funcoding.ai/agents/openclaw/help/troubleshooting/)：常规故障排查和常见问题。
