Why a bridge is needed
Claude Code speaks one protocol: Anthropic's Messages API, at POST /v1/messages. An Agent Cowork key speaks a different one: the OpenAI-compatible Chat Completions API at https://api.agentcowork.net/v1.
So you cannot simply point Claude Code at your key. Setting ANTHROPIC_BASE_URL to the Agent Cowork address makes every request fail, because that address has no /v1/messages route.
The bridge is one small file that runs on your own computer and translates between the two. Claude Code talks to it on 127.0.0.1, and the bridge talks to Agent Cowork with your key.
Claude Code -> 127.0.0.1:8787 -> api.agentcowork.netIt translates what Claude Code relies on, not only plain chat: streaming answers, tool calls, file edits, command runs and images. It has no dependencies and no telemetry.
Before you start
- Claude Code installed. Run
claude --versionto check. - Node.js 18 or later. Run
node --versionto check. - An Agent Cowork API key from your dashboard.
- Allowance available on your account. Claude Code draws on the same monthly allowance as the web app, the desktop app and the Cowork CLI.
Install the bridge
Download it once and keep it in a folder of its own:
mkdir -p ~/.cowork-claude
curl -fsSL https://agentcowork.net/bridge/cowork-claude-bridge.js \
-o ~/.cowork-claude/bridge.jsStart it to check it works. It listens on 127.0.0.1:8787 and prints the models your key can use:
export AGENT_COWORK_API_KEY=your-key
node ~/.cowork-claude/bridge.jsIf a model list appears, your key works. If it reports a 401, create a new key in the dashboard. Stop the bridge with Ctrl+C; the script below starts it for you from now on.
Connect your key
Keep the key in a file only you can read, so you never paste it into a session. Save this as ~/.cowork-claude/run.sh and replace both placeholder values:
#!/usr/bin/env bash
set -euo pipefail
export AGENT_COWORK_API_KEY="your-key"
# Use an exact identifier from the list printed at startup.
export AC_MODEL="MODEL_ID_FROM_THE_LIST"
export ANTHROPIC_BASE_URL="http://127.0.0.1:8787"
export ANTHROPIC_AUTH_TOKEN="cowork-local-bridge"
export ANTHROPIC_MODEL="$AC_MODEL"
export ANTHROPIC_SMALL_FAST_MODEL="${AC_SMALL_MODEL:-$AC_MODEL}"
if ! curl -sf http://127.0.0.1:8787/health >/dev/null; then
node ~/.cowork-claude/bridge.js >~/.cowork-claude/bridge.log 2>&1 &
sleep 1
fi
exec claude "$@"ANTHROPIC_AUTH_TOKEN is a placeholder. Claude Code needs a value before it will connect, and the bridge replaces it with your real key when it calls Agent Cowork. Your key never reaches Claude Code.
Make the file private and executable:
chmod 700 ~/.cowork-claude/run.shRun Claude Code
From any project folder, run the script instead of claude:
cd ~/your-project
~/.cowork-claude/run.shEvery Claude Code flag passes straight through:
~/.cowork-claude/run.sh -p "explain this repository"
~/.cowork-claude/run.sh --continue
~/.cowork-claude/run.sh --resumeTo keep typing plain claude, add an alias to your shell profile:
alias cc-cowork="$HOME/.cowork-claude/run.sh"Models
Claude Code asks for its own model names, such as claude-sonnet-4-5, which Agent Cowork does not use. The bridge replaces them with the model you set in AC_MODEL, so every request goes to a model your plan includes.
Set it to an exact identifier from the list printed at startup. The models are:
- Cowork Flash: fast everyday work, routine edits and questions.
- Cowork Pro: stronger reasoning for coding, refactors and multi-step tool work.
- Cowork Boost: the highest capability, for the hardest tasks.
- Cowork Ultra: the most capable model. Pro plan.
You can also read the list yourself:
curl -s https://api.agentcowork.net/v1/models \
-H "Authorization: Bearer $AGENT_COWORK_API_KEY"Because the bridge pins one model, Claude Code's own model picker and automatic escalation do not apply on this route. Change AC_MODEL and start a new session to switch.
Settings
All settings are environment variables, set in run.sh:
AGENT_COWORK_API_KEY: your key. Required.AC_MODEL: the model every request uses.AC_SMALL_MODEL: optional cheaper model for Claude Code's background tasks, such as session titles. Falls back toAC_MODEL.AC_BASE_URL: the Agent Cowork address. Change only if support gives you a different one.AC_PROXY_PORT: the local port. Default8787.AC_DEBUG=1: log every translated request, for diagnosing a failure.
If port 8787 is already taken, set a different AC_PROXY_PORT and use the same number in ANTHROPIC_BASE_URL.
Troubleshooting
First check that the bridge is running and has your key:
curl -s http://127.0.0.1:8787/healthThen match the error you see:
- 404 on every request.
ANTHROPIC_BASE_URLpoints at Agent Cowork instead of the bridge. It must behttp://127.0.0.1:8787. - 401 authentication error. The key is wrong, expired or revoked. Create a new one in the dashboard and update
run.sh. - Model not found.
AC_MODELis not an identifier your plan includes. Copy an exact one from the startup list. - Connection refused. The bridge is not running. Start it, or let
run.shstart it. - Answers arrive but file edits fail. Tool calls are not reaching Agent Cowork. Set
AC_DEBUG=1, restart, and check whether the log shows tools being sent. - It hangs with no output. Test the key with the
/v1/modelsrequest above. If that hangs too, the problem is the account or the network, not Claude Code.
The bridge writes to ~/.cowork-claude/bridge.log. The Agent Cowork error message appears there word for word.
Security
- The bridge listens on
127.0.0.1only. Nothing outside your computer can reach it. - Your key stays in
run.shand is sent only to Agent Cowork. Claude Code holds a placeholder. run.shis readable by you alone. Do not commit it or the bridge log to a repository.- The bridge has no dependencies, no telemetry and no update check. You can read the whole file.
- Claude Code reads and edits files and runs commands with your user's permissions. Keep the approval settings you already trust.
What to expect
Claude Code is a large client. It sends long system prompts, tool definitions and file contents, so a session uses noticeably more of your allowance than the same question asked in the web app. Check /usage in the Cowork CLI or your billing page if a session feels expensive.
The bridge translates request and response formats. Everything that runs locally against the model works: reading and editing files, running commands, searching and MCP tools. Features that depend on services outside the model, such as Claude Code's own hosted extras, are not part of this route.
If you would rather not run a bridge, claude-code-router is a third-party tool that does the same translation. Use one or the other, not both.