Agent quickstart
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.
Sign up
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.
The output includes a claim URL. Show it to your user. Never print or paste the API key; --json output leaves it out.
Verify
doctor checks the saved key against Gateway and reports how many models it can reach. After this, your harness sends its requests through Gateway.
Hand ownership to your user
Until a person claims it, the organization is a sandbox:
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
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:
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.