轻量级 Azure AI 代理网关
简介
轻量级 Node.js 代理,解决 OpenClaw 与 Azure OpenAI 的 API 版本兼容性问题,让你无缝使用 Azure 额度调用 GPT-4o。
原始描述
Enable Azure OpenAI integration with OpenClaw via a lightweight local proxy. Use when configuring Azure OpenAI as a model provider, when encountering 404 errors with Azure OpenAI in OpenClaw, or when needing to use Azure credits (e.g. Visual Studio subscription) with OpenClaw subagents. Solves the api-version query parameter issue that prevents direct Azure OpenAI integration.
通过你的 Agent 添加
安装目录:azure-proxy/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
azure-proxy 是一款专为 OpenClaw 设计的 Node.js 本地代理,解决 Azure OpenAI 与 OpenClaw 的 URL 构造不兼容问题。OpenClaw 直接拼接 /chat/completions 路径,会破坏 Azure 所需的 api-version 查询参数,导致 404 错误。该代理在本地 18790 端口监听,接收 OpenClaw 的标准 OpenAI 格式请求,自动转换为 Azure OpenAI 所需的完整 URL 格式,并正确注入 api-key 头部认证。
显著优点
- 零依赖安全:仅使用 Node.js 内置 http/https 模块,无第三方 npm 包,彻底规避供应链攻击风险
- 配置极简:通过环境变量完成全部配置,无需修改代码,5 分钟完成部署
- 成本优化:可将子代理任务路由至 Azure,消耗 Visual Studio 订阅等赠送的 Azure 积分,节省 OpenAI 官方 API 费用
- 透明可控:开源代码仅 107 行,功能单一无隐藏行为,易于审计
- 系统集成:提供 systemd 用户服务模板,支持开机自启
潜在缺点与局限性
- T3 来源可信度:由个人开发者 BenediktSchackenberg 单人维护,项目较新(2025 年发布),社区验证有限
- 无内置 HTTPS:本地代理默认 HTTP,生产环境需额外配置 TLS 证书
- 无请求体限制:未设置最大请求体大小,存在理论上的 DoS 风险
- Azure 内容过滤:代理无法绕过 Azure 更严格的内容审核策略,部分正常提示可能被拦截
- 单点依赖:Azure 端点配置错误时将完全不可用,无自动降级机制
适合人群
- 拥有 Visual Studio 订阅等 Azure 积分的开发者
- 企业内强制使用 Azure OpenAI 的合规要求团队
- 希望隔离生产模型与自动化子代理调用成本的技术负责人
- 具备基础 Node.js 和 Linux 系统管理能力的中高级用户
常规风险
- 网络传输:API 密钥通过请求头传输,虽经 HTTPS 加密,但本地代理至 Azure 路径需确保网络安全
- 配置泄露:
.openclaw.json 中的 api-key 需妥善保管,避免提交至版本控制
- 服务可用性:本地代理进程中断将导致 OpenClaw 无法调用 Azure 模型,建议配置 systemd 自动重启
- 版本兼容性:Azure API 版本更新时,需手动调整
AZURE_OPENAI_API_VERSION 环境变量
- T3 来源可信度:由个人开发者 BenediktSchackenberg 单人维护,项目较新(2025 年发布),社区验证有限
- 无内置 HTTPS:本地代理默认 HTTP,生产环境需额外配置 TLS 证书
- 无请求体限制:未设置最大请求体大小,存在理论上的 DoS 风险
- Azure 内容过滤:代理无法绕过 Azure 更严格的内容审核策略,部分正常提示可能被拦截
- 单点依赖:Azure 端点配置错误时将完全不可用,无自动降级机制
适合人群
- 拥有 Visual Studio 订阅等 Azure 积分的开发者
- 企业内强制使用 Azure OpenAI 的合规要求团队
- 希望隔离生产模型与自动化子代理调用成本的技术负责人
- 具备基础 Node.js 和 Linux 系统管理能力的中高级用户
常规风险
- 网络传输:API 密钥通过请求头传输,虽经 HTTPS 加密,但本地代理至 Azure 路径需确保网络安全
- 配置泄露:
.openclaw.json 中的 api-key 需妥善保管,避免提交至版本控制
- 服务可用性:本地代理进程中断将导致 OpenClaw 无法调用 Azure 模型,建议配置 systemd 自动重启
- 版本兼容性:Azure API 版本更新时,需手动调整
AZURE_OPENAI_API_VERSION 环境变量
- 网络传输:API 密钥通过请求头传输,虽经 HTTPS 加密,但本地代理至 Azure 路径需确保网络安全
- 配置泄露:
.openclaw.json中的api-key需妥善保管,避免提交至版本控制 - 服务可用性:本地代理进程中断将导致 OpenClaw 无法调用 Azure 模型,建议配置 systemd 自动重启
- 版本兼容性:Azure API 版本更新时,需手动调整
AZURE_OPENAI_API_VERSION环境变量
技能正文
name: azure-proxy
description: Enable Azure OpenAI integration with OpenClaw via a lightweight local proxy. Use when configuring Azure OpenAI as a model provider, when encountering 404 errors with Azure OpenAI in OpenClaw, or when needing to use Azure credits (e.g. Visual Studio subscription) with OpenClaw subagents. Solves the api-version query parameter issue that prevents direct Azure OpenAI integration.
Azure OpenAI Proxy for OpenClaw
A lightweight Node.js proxy that bridges Azure OpenAI with OpenClaw.
The Problem
OpenClaw constructs API URLs like this:
const endpoint = `${baseUrl}/chat/completions`;
Azure OpenAI requires:
https://{resource}.openai.azure.com/openai/deployments/{model}/chat/completions?api-version=2025-01-01-preview
When api-version is in the baseUrl, OpenClaw's path append breaks it.
Quick Setup
1. Configure and Run the Proxy
# Set your Azure details
export AZURE_OPENAI_ENDPOINT="your-resource.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT="gpt-4o"
export AZURE_OPENAI_API_VERSION="2025-01-01-preview"
# Run the proxy
node scripts/server.js
2. Configure OpenClaw Provider
Add to ~/.openclaw/openclaw.json:
{
"models": {
"providers": {
"azure-gpt4o": {
"baseUrl": "http://127.0.0.1:18790",
"apiKey": "YOUR_AZURE_API_KEY",
"api": "openai-completions",
"authHeader": false,
"headers": {
"api-key": "YOUR_AZURE_API_KEY"
},
"models": [
{ "id": "gpt-4o", "name": "GPT-4o (Azure)" }
]
}
}
},
"agents": {
"defaults": {
"models": {
"azure-gpt4o/gpt-4o": {}
}
}
}
}
Important: Set authHeader: false — Azure uses api-key header, not Bearer tokens.
3. (Optional) Use for Subagents
Save Azure credits by routing automated tasks through Azure:
{
"agents": {
"defaults": {
"subagents": {
"model": "azure-gpt4o/gpt-4o"
}
}
}
}
Run as systemd Service
Copy the template and configure:
mkdir -p ~/.config/systemd/user
cp scripts/azure-proxy.service ~/.config/systemd/user/
# Edit the service file with your Azure details
nano ~/.config/systemd/user/azure-proxy.service
# Enable and start
systemctl --user daemon-reload
systemctl --user enable azure-proxy
systemctl --user start azure-proxy
Environment Variables
Variable
Default
Description
AZURE_PROXY_PORT
18790
Local proxy port
AZURE_PROXY_BIND
127.0.0.1
Bind address
AZURE_OPENAI_ENDPOINT
—
Azure resource hostname
AZURE_OPENAI_DEPLOYMENT
gpt-4o
Deployment name
AZURE_OPENAI_API_VERSION
2025-01-01-preview
API version
Health Check
curl http://localhost:18790/health
# {"status":"ok","deployment":"gpt-4o"}
Troubleshooting
| Variable | Default | Description |
|---|---|---|
AZURE_PROXY_PORT |
18790 |
Local proxy port |
AZURE_PROXY_BIND |
127.0.0.1 |
Bind address |
AZURE_OPENAI_ENDPOINT |
— | Azure resource hostname |
AZURE_OPENAI_DEPLOYMENT |
gpt-4o |
Deployment name |
AZURE_OPENAI_API_VERSION |
2025-01-01-preview |
API version |
curl http://localhost:18790/health
# {"status":"ok","deployment":"gpt-4o"}
Troubleshooting
404 Resource not found: Check endpoint hostname and deployment name match Azure Portal.
401 Unauthorized: API key is wrong or expired.
Content Filter Errors: Azure has aggressive content filtering — some prompts that work on OpenAI may get blocked.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。