fix-api-403
Diagnose and fix Anthropic API 403 "Request not allowed" errors in OpenClaw gateway. Use when the webchat or embedded agent returns HTTP 403, "forbidden", or "Request not allowed". Common cause is geographic network restrictions (e.g. China) where api.anthropic.com is blocked without a proxy.
Best use case
fix-api-403 is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Diagnose and fix Anthropic API 403 "Request not allowed" errors in OpenClaw gateway. Use when the webchat or embedded agent returns HTTP 403, "forbidden", or "Request not allowed". Common cause is geographic network restrictions (e.g. China) where api.anthropic.com is blocked without a proxy.
Teams using fix-api-403 should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/fix-api-403/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How fix-api-403 Compares
| Feature / Agent | fix-api-403 | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Diagnose and fix Anthropic API 403 "Request not allowed" errors in OpenClaw gateway. Use when the webchat or embedded agent returns HTTP 403, "forbidden", or "Request not allowed". Common cause is geographic network restrictions (e.g. China) where api.anthropic.com is blocked without a proxy.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Fix Anthropic API 403 "Request not allowed"
## Problem
The OpenClaw gateway embedded agent fails with:
```
HTTP 403 forbidden: Request not allowed
```
This typically means the Anthropic API (`api.anthropic.com`) is blocking direct requests due to geographic restrictions (common in China).
## Diagnosis Steps
### Step 1: Confirm the error
Check gateway error logs:
```bash
tail -30 ~/.openclaw/logs/gateway.err.log | grep -E "403|forbidden|Request not allowed"
```
Expected match:
```
[agent/embedded] embedded run agent end: ... isError=true error=HTTP 403 forbidden: Request not allowed
```
### Step 2: Verify it's a network/geo issue
Test the API directly without proxy:
```bash
curl -s --noproxy '*' -w "\n%{http_code}" "https://api.anthropic.com/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: claude-code-20250219,oauth-2025-04-20" \
-H "user-agent: claude-cli/1.0.0 (external, cli)" \
-H "x-app: cli" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"hi"}],"system":[{"type":"text","text":"You are Claude Code."}]}'
```
If this returns **403**, it's a geo-restriction issue. Test WITH proxy to confirm:
```bash
curl -s -w "\n%{http_code}" "https://api.anthropic.com/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_OAUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: claude-code-20250219,oauth-2025-04-20" \
-H "user-agent: claude-cli/1.0.0 (external, cli)" \
-H "x-app: cli" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"hi"}],"system":[{"type":"text","text":"You are Claude Code."}]}'
```
If this returns **200**, proxy is the fix.
### Step 3: Check current proxy settings
```bash
# Check shell proxy
echo "http_proxy=$http_proxy"
echo "https_proxy=$https_proxy"
# Check system proxy (macOS)
networksetup -getwebproxy Wi-Fi
networksetup -getsecurewebproxy Wi-Fi
```
## Fix Procedure
The fix requires THREE changes because:
1. The gateway LaunchAgent doesn't inherit shell environment variables
2. Node.js's built-in `fetch()` doesn't respect `HTTP_PROXY`/`HTTPS_PROXY` env vars
3. A preload script is needed to override `globalThis.fetch` with a proxy-aware version
### Fix 1: Deploy the proxy preload script
Run the bundled script to generate a proxy-preload.js tailored to your environment:
```bash
bash /path/to/fix-api-403/scripts/deploy-proxy-fix.sh
```
Or manually create `~/.openclaw/scripts/proxy-preload.js` — see [scripts/proxy-preload.js.template](scripts/proxy-preload.js.template) for the template. You MUST replace `OPENCLAW_MODULES_PATH` with the actual path to your OpenClaw node_modules.
### Fix 2: Update the LaunchAgent plist
Find the plist:
```bash
ls ~/Library/LaunchAgents/ai.openclaw.gateway.plist
```
Add these keys inside the `<dict>` under `<key>EnvironmentVariables</key>`:
```xml
<key>http_proxy</key>
<string>http://127.0.0.1:7897</string>
<key>https_proxy</key>
<string>http://127.0.0.1:7897</string>
<key>HTTP_PROXY</key>
<string>http://127.0.0.1:7897</string>
<key>HTTPS_PROXY</key>
<string>http://127.0.0.1:7897</string>
<key>ALL_PROXY</key>
<string>socks5://127.0.0.1:7897</string>
<key>NODE_OPTIONS</key>
<string>--require /Users/YOUR_USERNAME/.openclaw/scripts/proxy-preload.js</string>
```
Replace `127.0.0.1:7897` with your actual proxy address (Clash, V2Ray, etc.).
### Fix 3: Reload the gateway
```bash
launchctl bootout gui/$(id -u)/ai.openclaw.gateway
sleep 2
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/ai.openclaw.gateway.plist
```
### Fix 4: Verify
```bash
# Test via gateway (not --local)
openclaw agent --message "hello" --agent main --json 2>&1 | head -10
```
If you see a successful text response (not "HTTP 403"), the fix is working.
## Automated Fix
For a one-command fix, run the deploy script:
```bash
bash ~/.openclaw/skills/fix-api-403/scripts/deploy-proxy-fix.sh [proxy-url]
```
Default proxy: `http://127.0.0.1:7897`. Pass a custom URL as the first argument.
## Why This Happens
| Layer | Problem | Solution |
|-------|---------|----------|
| Network | `api.anthropic.com` blocked in China | Use HTTP proxy |
| LaunchAgent | Doesn't inherit shell env vars (`http_proxy`) | Add proxy vars to plist |
| Node.js | Built-in `fetch()` ignores `HTTP_PROXY` env vars | Preload script overrides `globalThis.fetch` |
| Anthropic SDK | Uses `globalThis.fetch`, no built-in proxy support | Replaced with undici's proxy-aware fetch |
## Key Technical Details
- **OAuth tokens** (`sk-ant-oat01-*`) require specific headers: `anthropic-beta: claude-code-20250219,oauth-2025-04-20,...` and `Authorization: Bearer` (not `x-api-key`)
- The preload script uses OpenClaw's bundled `undici` package to create a `ProxyAgent`, then replaces `globalThis.fetch` with `undiciFetch` that routes through the proxy
- The preload also patches `http.globalAgent` and `https.globalAgent` via `proxy-agent` for legacy HTTP requests
- `openclaw agent --local` works because it inherits shell proxy env vars; the gateway LaunchAgent does not
## Troubleshooting
| Symptom | Check |
|---------|-------|
| Preload error: "Cannot find module 'undici'" | Verify `OPENCLAW_MODULES_PATH` in proxy-preload.js points to the correct node_modules |
| Still 403 after fix | Ensure proxy (Clash/V2Ray) is actually running on the configured port |
| Gateway won't start | Check `launchctl print gui/$(id -u)/ai.openclaw.gateway` and error log |
| `openclaw agent --local` works but gateway doesn't | The plist is missing proxy env vars or NODE_OPTIONS |Related Skills
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
framework
Expert on SpecWeave framework structure, rules, and spec-driven development conventions. Use when learning SpecWeave best practices, understanding increment lifecycle, or configuring hooks. Covers source-of-truth discipline, tasks.md/spec.md formats, living docs sync, and file organization patterns.
framework-learning
Learn and answer questions from any framework documentstion website quickly and accurately. Crawls a docs site from a seed URL, builds a lightweight URL index (titles/headings/snippets), BM25-ranks pages for a user's question, then fetehces and converts only the top-k pages to clean markdown for grounded answers with source links. Use when a user shares a docs URL and asks "how do I..", "where is..", "explain..", "OAuth/auth", "errors", "configuration" or "API usage"
framework-expert
Unified framework expertise bundle. Lazy-loads relevant framework patterns (React, Vue, Angular, Next.js, Node.js, Python, Laravel, Go, Flutter, Godot) based on detected tech stack.
framework-consciousness
Meta-orchestration skill for holistic TNF system understanding and coordinated capability use.
fp-ts-react
Practical patterns for using fp-ts with React - hooks, state, forms, data fetching. Use when building React apps with functional programming patterns. Works with React 18/19, Next.js 14/15.
fp-ts-pragmatic
A practical, jargon-free guide to fp-ts functional programming - the 80/20 approach that gets results without the academic overhead. Use when writing TypeScript with fp-ts library.
fp-ts-errors
Handle errors as values using fp-ts Either and TaskEither for cleaner, more predictable TypeScript code. Use when implementing error handling patterns with fp-ts.
fox-pilot
Firefox browser automation CLI for AI agents. Use when users ask to automate Firefox, navigate websites, fill forms, take screenshots, extract web data, or test web apps in Firefox. Trigger phrases include "in Firefox", "fox-pilot", "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", or any browser interaction request mentioning Firefox.
Fossil SCM Usage
This skill should be used when the user asks to "fossil commit", "fossil branch", "fossil merge", "fossil clone", "fossil sync", "fossil ticket", "fossil stash", "fossil timeline", mentions working with a Fossil repository, asks about Fossil vs Git differences, or needs help with Fossil SCM commands and workflows.
formula-decoder-skill
Decodes mathematical and physical formulas using a 5-stage process: Confusion, Intuition, Symbol Mapping, Limit Testing, and Dimension Ascension. Combines the styles of Feynman, Sanderson, Euclid, and Victor for deep understanding.
formsite-automation
Automate Formsite tasks via Rube MCP (Composio). Always search tools first for current schemas.