setup-gateway CLI

setup-gateway writes an OpenAI-compatible gateway into the Claude Code, OpenCode and Codex CLI configs in one pass, with a backup.

  • 444 ★ on the repository
  • Last commit
  • MIT
CLI

Extended access

Why this level

  • Overwrites client settings files and stores the API key in a config as plain text.
  • Sends the key to `/v1/models` of the given gateway, so the address needs checking.
All reasons and checks

sinholms/setup-gateway

Install

Manual install

node bin/setup-gateway.mjs

The first Quick start command in the README. Clone the repository first, no package installation is needed.

Access and checks

How we review

Extended accessThe tool runs code or makes network calls and only reads external data.

  • Overwrites client settings files and stores the API key in a config as plain text.
  • Sends the key to `/v1/models` of the given gateway, so the address needs checking.

This is third-party code. Review the repository files before installing.

What it does

setup-gateway is a zero-dependency CLI on Node.js 18 or newer that configures any gateway exposing `/v1` for three clients. You enter the gateway address, key and model, and the command calls `GET <baseURL>/v1/models` and lets you pick a model from the list. For Claude Code it writes `~/.claude/settings.json` with `ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY` and the model. For OpenCode it creates a provider block in `opencode.json`, and for Codex CLI a `[model_providers.gateway]` block in `config.toml` plus a `gateway-catalog.json` model catalog. Other settings and TOML comments are preserved, a backup is made before writing and `restore` brings it back.

Who it is for. Developers and teams who reach models through LiteLLM, OpenRouter or an internal proxy and want to connect it to three clients with one command.

Good fit when

  • The company issued a gateway address and key and three clients must be set up the same way.
  • A gateway model should appear in the `/model` list in Codex CLI.
  • Setup must be reproduced in CI through flags and `GATEWAY_BASE_URL` variables.
  • A config edit went wrong and the previous one should come back through `restore`.

Not a fit when

  • The client uses no OpenAI-compatible gateway.
  • A key cannot be stored as plain text in a config.
  • The gateway exposes only classic Chat Completions for Codex CLI.

Example request

Set up Codex CLI for my gateway at https://gw.example.com with model deepseek-v4, make a backup and show `status` with the key masked.

Limitations

The API key is written to the config as plain text: the README warns about this and offers `status` with masking. Codex CLI needs a gateway with the Responses API (`wire_api = "responses"`), Codex 0.105.0 or newer for the model catalog and a restart after setup. An `http://` address triggers a warning that the `--yes` flag skips. The README is in Indonesian. The last commit was in August 2026.

How to disable. Run `node setup-gateway.mjs restore claude` (or `opencode`, `codex`) to bring back the latest backup. Nothing is installed globally: deleting the cloned directory is enough.

FAQ

What is written to the Claude Code config?

`ANTHROPIC_BASE_URL`, `ANTHROPIC_API_KEY` and `model` in `~/.claude/settings.json` or the `$CLAUDE_CONFIG_DIR` directory.

How do I run it without prompts?

Pass `--base-url`, `--api-key`, `--model` and `--yes`, or set `GATEWAY_BASE_URL`, `GATEWAY_API_KEY` and `GATEWAY_MODEL`.

How do I go back to the previous setup?

`node setup-gateway.mjs restore codex` restores the latest backup. In a terminal a backup selection menu opens.

Does a Chat Completions gateway work?

Not for Codex CLI: it needs the Responses API. A translating proxy such as LiteLLM helps.

Is there a self-test?

Yes, `--selftest` checks pure functions without touching real configs, which suits CI.

Discussion

No questions or reviews yet.

CLI tools
Official

The GoModel gateway puts MCP servers behind one protected address and keeps their tokens out of the agent's reach.

MCP serverBroad access1.3KRepository stars

A self-hosted gateway between AI apps and models, MCP tools and A2A agents: policy, budgets, routing and an audit trail

CLIBroad access219Repository stars

A CLI runs a model and MCP-tool gateway with owned API keys, format translation, routing and request logs.

CLIExtended access786Repository stars

A self-hosted gateway for multiple LLM keys and providers: rotation, failover, request logs and usage accounting

CLIBroad access7.2KRepository stars
Official

Tingly Box runs a local model gateway: Claude Code, Codex and OpenCode use one address and requests go to the providers you choose

CLIBroad access381Repository stars
Official

A launcher that starts Claude Code, Codex, Gemini CLI and other agents with Tailscale Aperture settings, with a bridge mode

CLIExtended access89Repository stars

README in short

The tool knows no provider, address or model in advance. It writes only the gateway blocks and preserves other settings.

README badge

Report a problem