@rpalegacy/opencode
v0.1.0
Published
OpenClaw provider for opencode — exposes Claude (claude-local) models via the OpenClaw proxy
Downloads
157
Maintainers
Readme
@rpalegacy/opencode
OpenClaw provider package for opencode.
Exposes Claude (claude-local) models — Claude Opus 4.6, Claude Sonnet 4.6, and Claude Haiku 4 — via the OpenClaw local proxy at localhost:3456.
Requirements
- OpenClaw running with
openclaw-claude-proxyactive OPENCLAW_API_KEYenvironment variable set (get it from your OpenClaw config)- Node.js >= 18
Setup
1. Install OpenClaw's Claude proxy
# Install the openclaw-claude-proxy if you haven't already
npm install -g openclaw-claude-proxy
openclaw-claude-proxyThe proxy runs at http://localhost:3456 and handles OAuth with your Claude Pro subscription.
2. Configure opencode
Add to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"openclaw": {
"npm": "@rpalegacy/opencode",
"env": ["OPENCLAW_API_KEY"]
}
}
}Or use the /connect command in opencode's TUI and enter:
- Provider ID:
openclaw - Base URL:
http://localhost:3456/v1 - API Key:
OPENCLAW_API_KEY(or set the env var directly)
3. Use it
# Set your API key
export OPENCLAW_API_KEY="sk-ant-..."
# Run opencode with the OpenClaw provider
opencode --provider openclaw --model claude-opus-4-6
# Or in opencode's TUI
/models # then select a Claude modelAvailable Models
| Model | Context | Reasoning | Tool Call | Vision | Cost | |-------|---------|-----------|-----------|--------|------| | Claude Opus 4.6 | 200K | ✅ | ✅ | ✅ | Free* | | Claude Sonnet 4.6 | 200K | ✅ | ✅ | ✅ | Free* | | Claude Haiku 4 | 200K | ✅ | ✅ | ✅ | Free* |
*Free via your Claude Pro subscription through the local proxy.带宽
How it works
@rpalegacy/opencode wraps the @ai-sdk/openai-compatible provider and configures it to point at OpenClaw's local proxy (localhost:3456). The proxy handles:
- OAuth authentication with your Claude Pro account
- Model routing (claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4)
- API compatibility (converts between OpenAI-compatible and Anthropic APIs)
Troubleshooting
"Model not found" errors
- Make sure
openclaw-claude-proxyis running - Verify
http://localhost:3456is accessible - Check that
OPENCLAW_API_KEYis set correctly
Authentication errors
- The proxy uses OAuth with your Claude Pro account
- Make sure your Claude Pro subscription is active
- Try restarting the proxy:
pkill -f openclaw-claude-proxy && openclaw-claude-proxy
License
MIT
