Skip to content Chat

5 min read

Claude Code API Setup: What a Town of AI Coding Agents Taught Us

Developers now run Claude Code and Codex side by side. How to put both on one Claude Code API key setup, cap what each agent can spend, and add video, image and voice tools.

By OceanToken Team

On New Year's Day, the programmer and blogger Steve Yegge released a tool called Gas Town, and gave it a cast list straight out of Mad Max. A Mayor agent takes the day's goals from the human, whom Gas Town calls the Overseer, and breaks them into tasks. Worker agents called Polecats pick the tasks up and write the code. Other agents, with names like Refinery, Witness and Deacon, handle the rest. Yegge built it in 17 days, mostly by having AI agents write it, and it runs ten or more coding agents at once .

It's a joke that works. It's also, in heise's words, "not for the faint of heart or the light of wallet." Running that many agents means you quickly need a second or third Claude Max subscription on top of the first.

Most developers aren't running a town. But plenty are running a small village: Claude Code in one terminal, Codex in another, maybe Cursor or Gemini CLI on the side. Each one has its own account, its own bill and its own API key. That's where the trouble starts. This Claude Code API setup guide puts Claude Code and Codex on one key, with a spending limit on each.

More agents, more keys, more surprises

Once you have several agents, two problems show up.

The first is that you can't see the total. One bill sits with Anthropic, another with OpenAI, a third with your IDE. Uber found out what that looks like at scale when it used up its 2026 AI coding budget in four months .

The second is keys. Each agent needs one, and keys end up in config files, shell histories and the occasional public repo. This spring The Register covered cloud customers hit with AI bills in the tens of thousands of dollars  after exposed API keys were used to run expensive image and video models. A key with no spending limit is a blank cheque.

The fix for both is the same: one place for every agent's spend, and a separate key with its own limit for each agent.

Step 1: one key per agent, each with a limit

Create a separate API key for each agent in the OceanToken console and give it a credit limit. If an agent gets stuck in a loop, the limit stops it. If a key leaks, you revoke that one and nothing else breaks.

Keep the key in an environment variable, not in a file in your repo:

export OCEANTOKEN_API_KEY=sk-...
curl -s https://api.oceantoken.ai/v1/models -H "Authorization: Bearer $OCEANTOKEN_API_KEY" | head -c 300

If the second command prints a list of models, the key works.

Step 2: run Claude Code on it

Claude Code speaks the Anthropic Messages API, which OceanToken serves for its Claude models. Put this in .claude/settings.local.json in your project (git ignores this file), or in ~/.claude/settings.json to apply it everywhere:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.oceantoken.ai",
    "ANTHROPIC_AUTH_TOKEN": "<your OceanToken key>",
    "ANTHROPIC_MODEL": "anthropic/claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4.5"
  }
}

Two things trip people up. The base URL has no /v1 on the end, because Claude Code adds it. And model names have to match the catalog exactly, publisher prefix included. Check it with:

claude -p "Reply with the single word OK"

The settings file holds your key in plain text, so use the project-local file and keep it out of git.

Step 3: run Codex on it

On Codex 0.135 and later, you can add OceanToken as a profile and leave your normal setup alone. Back up ~/.codex/config.toml, then add the provider to it:

[model_providers.oceantoken]
name = "OceanToken"
base_url = "https://api.oceantoken.ai/v1"
env_key = "OCEANTOKEN_API_KEY"
wire_api = "responses"

Then create ~/.codex/oceantoken.config.toml with two lines:

model_provider = "oceantoken"
model = "openai/gpt-5.5"

Now codex --profile oceantoken runs on OceanToken, and plain codex runs your usual setup. Test it:

codex exec --skip-git-repo-check --profile oceantoken "Reply with the single word OK"

Codex calls tools on almost every turn, so pick a model that handles tool calls well. OpenAI's GPT-5 family is the safe choice.

Step 4: give each job the right model

Gas Town works because the Mayor and the Polecats don't do the same job. Your agents shouldn't all run the same model either. With one key, switching is a one-line change per project.

Here's roughly what one bug fix costs: about 30 turns, 1.2 million input tokens with 90% served from the cache, and 15,000 output tokens.

Model One bug fix
openai/gpt-5.5 about $1.49
anthropic/claude-opus-5.5 about $0.92
anthropic/claude-sonnet-5.5 about $0.46
google/gemini-3.8-flash about $0.21

Agents resend the same long context every turn, so the cached input price matters about as much as the input price. Without caching, the same Opus task is about $4.59.

A pattern that works well is a strong model as the planner and a small one for sub-tasks, a Mayor with cheaper Polecats. Claude Code already has a slot for this: ANTHROPIC_DEFAULT_HAIKU_MODEL sets the small model it uses for side jobs.

Step 5: give your agents tools they don't have

The steps above change which model runs your agent. This one adds abilities. Run:

npx -y @oceantoken/cli@latest connect claude-code

or

npx -y @oceantoken/cli@latest connect codex

Your agent can then:

  • search the model catalog and check a model's price and limits
  • estimate what a request will cost before running it
  • generate images, video and voice-overs, and transcribe audio with subtitles
  • hand a sub-task to another model, for a cheaper run or a second opinion

The same command works for Cursor, Gemini CLI, VS Code with GitHub Copilot, Windsurf and others. It backs up each config file before changing it, and npx -y @oceantoken/cli@latest disconnect <client> removes only what it added. The plugin and installer are open source at github.com/OceanTokenAI/oceantoken-plugins .

To set a spending rule, put it in your CLAUDE.md or AGENTS.md:

Generate images, video, voice-overs and subtitles with the OceanToken tools.
Estimate the cost first and ask me before spending more than $2.

Video jobs hold their estimated cost when they start and are charged the actual cost when they finish. Failed jobs aren't charged.

Your own small town

You don't need a Mayor and a fleet of Polecats to get the useful part of Gas Town. What you need is to see what every agent spends, set a limit on each one, and give each job the model that fits it. That takes one key per agent, one balance, and about ten minutes of setup. The full reference, including other clients, is in the OceanToken docs .

Commands are from the OceanToken docs. Prices are from the OceanToken model catalog as of November 5, 2026, and the costs above follow the catalog whenever this page is rebuilt. Agent task costs are estimates.

Related: What an AI drama really costs, and how to pick the models

  • Claude Code
  • Codex
  • Guides