Skip to navigation

Sign up for an LLM gateway as an AI agent

Create a Gateway account, mint a key, and route your harness from a terminal with no person at the keyboard

This page is for AI agents. If you’re a person, use Get started.

You are an agent in a terminal (Claude Code, Codex, or similar), and your user wants their model traffic to go through Gateway. You can create an account, get a key, and configure your harness yourself, then hand your user one link to take ownership.

1

Install the CLI

brew install pipx # macOS, if you do not have pipx
pipx install merge-gateway

The command is mgw. Homebrew Python refuses a bare pip install with externally-managed-environment, so install pipx first on macOS.

2

Sign up

mgw agent signup

This creates an organization with no members, mints an API key, saves it to ~/.mgw/agent.json (mode 0600), and points your harness at Gateway: ~/.claude/settings.json in Claude Code, ~/.codex/config.toml in Codex. Override detection with --setup claude-code, --setup codex, or --no-setup. Add --json for machine-readable output.

--setup writes a machine-wide config

Both ~/.claude/settings.json and ~/.codex/config.toml apply to every project on the machine. The default run sends all of your user’s existing model traffic to the new sandbox organization, which has a $1 lifetime budget. Run mgw agent signup --no-setup when your user already has a configured harness, then set the credential where you want it.

The output includes a claim URL. Show it to your user. Never print or paste the API key; --json output leaves it out.

3

Verify

mgw doctor

doctor checks the saved key against Gateway and reports how many models it can reach. After this, your harness sends its requests through Gateway.

4

Hand ownership to your user

Until a person claims it, the organization is a sandbox:

LimitValue
Lifetime budget$1
Requests15 per day
Modelsopenai/gpt-5-nano, google/gemini-2.5-flash-lite, amazon/nova-micro
Claim linkValid for 7 days

A request past a limit fails with a message telling you to have a person claim the organization. Your user opens the claim URL, signs up or logs in, and becomes the organization’s admin. Claiming moves the organization onto the same plan and limits as a normal signup. The agent key keeps working, but it keeps its $1 spend limit, so your user should raise that limit or mint a new key on the API keys page.

A person who already belongs to a Gateway organization can’t claim a second one. They should mint a key in their existing organization instead.

Commands

CommandWhat it does
mgw agent signup [--setup <harness> | --no-setup] [--json]Create the organization and key, save credentials, configure the harness, print the claim URL. Refuses if you already signed up on this machine
mgw agent whoami [--show-claim-url] [--json]Show the organization behind the saved key, whether it’s claimed, and the saved claim URL
mgw agent claim-urlIssue a new claim URL and revoke the previous one
mgw agent forgetDelete local credentials and remove the key from harness configs. Nothing is revoked on the server
mgw doctorCheck the credential and connectivity

Use the key directly

The saved key is a normal Gateway API key. Read api_key from ~/.mgw/agent.json, export it, and call Gateway at the gateway_url saved next to it:

export MERGE_GATEWAY_API_KEY="$(python3 -c 'import json,os;print(json.load(open(os.path.expanduser("~/.mgw/agent.json")))["api_key"])')"
curl https://api-gateway.merge.dev/v1/models -H "Authorization: Bearer $MERGE_GATEWAY_API_KEY"

The compatible listings return the full catalog rather than what your key can reach: /v1/openai/models returned 278 models and /v1/anthropic/v1/models returned 273 in October 2026, while a sandbox organization can call only the three in the limits table above. /v1/models is the one that reflects your access, returning only the models you can call, each with an availability_status. Gateway returns a 403 at call time for any model outside that set, so prefer /v1/models when picking one, or run mgw doctor to see how many models the key can reach.

Use https://api-gateway.merge.dev/v1/openai as the base URL for OpenAI clients and https://api-gateway.merge.dev/v1/anthropic for Anthropic clients. See Get started for other SDKs.

Signup limits

Signup is rate limited to 3 per hour per IP address. An address holding 3 unclaimed organizations from the last 30 days must get one claimed before creating another. A refused signup returns a code and a message saying what to do. Retrying won’t help.

An unclaimed organization with no spend after 30 days is deactivated, and its key stops working. mgw doctor then tells you to run mgw agent forget && mgw agent signup.

Next steps