DocumentationClaude Code

Claude Code

Use the Claude Code CLI on your Agent Cowork account. The same commands and the same local tools, with the work drawing on your Cowork allowance.

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.

Terminal commands
Claude Code  ->  127.0.0.1:8787  ->  api.agentcowork.net

It 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 --version to check.
  • Node.js 18 or later. Run node --version to 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:

Terminal commands
mkdir -p ~/.cowork-claude
curl -fsSL https://agentcowork.net/bridge/cowork-claude-bridge.js \
  -o ~/.cowork-claude/bridge.js

Start it to check it works. It listens on 127.0.0.1:8787 and prints the models your key can use:

Terminal commands
export AGENT_COWORK_API_KEY=your-key
node ~/.cowork-claude/bridge.js

If 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:

Terminal commands
#!/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:

Terminal commands
chmod 700 ~/.cowork-claude/run.sh

Run Claude Code

From any project folder, run the script instead of claude:

Terminal commands
cd ~/your-project
~/.cowork-claude/run.sh

Every Claude Code flag passes straight through:

Terminal commands
~/.cowork-claude/run.sh -p "explain this repository"
~/.cowork-claude/run.sh --continue
~/.cowork-claude/run.sh --resume

To keep typing plain claude, add an alias to your shell profile:

Terminal commands
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:

Terminal commands
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 to AC_MODEL.
  • AC_BASE_URL: the Agent Cowork address. Change only if support gives you a different one.
  • AC_PROXY_PORT: the local port. Default 8787.
  • 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:

Terminal commands
curl -s http://127.0.0.1:8787/health

Then match the error you see:

  • 404 on every request. ANTHROPIC_BASE_URL points at Agent Cowork instead of the bridge. It must be http://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_MODEL is 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.sh start 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/models request 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.1 only. Nothing outside your computer can reach it.
  • Your key stays in run.sh and is sent only to Agent Cowork. Claude Code holds a placeholder.
  • run.sh is 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.