# AI use cases for Setup Gateway (Sinholms/setup-gateway)

Repo: [Sinholms/setup-gateway](https://github.com/Sinholms/setup-gateway) | Use cases: 4 | Page: https://dedupedai.com/use-cases/sinholms-setup-gateway/

A zero-dependency Node.js CLI that points Claude Code, OpenCode, and Codex CLI at any OpenAI-compatible gateway, with automatic backups and a restore command.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Point Claude Code at your own OpenAI-compatible gateway: https://dedupedai.com/use-cases/sinholms-setup-gateway/point-claude-code-at-gateway/
- Set up Codex CLI with gateway models in the /model picker: https://dedupedai.com/use-cases/sinholms-setup-gateway/set-up-codex-cli-model-picker/
- Restore the last working config after a bad gateway change: https://dedupedai.com/use-cases/sinholms-setup-gateway/roll-back-broken-tool-config/
- Run the built-in selftest in CI before publishing a release: https://dedupedai.com/use-cases/sinholms-setup-gateway/run-selftest-before-release/

## How to point Claude Code at your own OpenAI-compatible gateway with Setup Gateway

Repo: [Sinholms/setup-gateway](https://github.com/Sinholms/setup-gateway) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Write the gateway URL, key, and model into Claude Code settings without losing existing config.

**Who it is for:** A developer or team lead who wants Claude Code to route through a company LiteLLM, OpenRouter, or internal proxy instead of the default endpoint.

**The problem:** Editing ~/.claude/settings.json by hand is error prone, and a wrong edit can break other environment settings the user already relies on.

**The outcome:** Claude Code uses the chosen gateway, the original settings are kept, and a timestamped backup exists for rollback.

### Steps

1. Clone the repo and run `node bin/setup-gateway.mjs claude` in a terminal to start the interactive setup.
2. Enter the Base URL, the API key, and pick a model from the list that appears.
3. Restart Claude Code so the new env values are read.
4. Run `node setup-gateway.mjs status` to confirm the base URL and model (the key is shown masked).

### Prompt to paste into your agent

```text
Work in the cloned repo Sinholms/setup-gateway. Run `node bin/setup-gateway.mjs claude --base-url <GATEWAY_BASE_URL> --api-key <API_KEY> --model <MODEL_ID> --yes` and report the written file path. Then run `node setup-gateway.mjs status` and verify the printed base URL and model match the values passed in.
```

### Caveat

Base URLs that start with http:// trigger a warning and need y/N confirmation, or --yes in non-interactive mode, because the key is sent without TLS.

Risk, credentials: The API key is written in plaintext into the Claude Code config file, so restrict that file's permissions and do not commit it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/sinholms-setup-gateway/point-claude-code-at-gateway/

## How to set up Codex CLI with gateway models in the /model picker with Setup Gateway

Repo: [Sinholms/setup-gateway](https://github.com/Sinholms/setup-gateway) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Configure Codex CLI to use a Responses API gateway and list extra gateway models in /model.

**Who it is for:** A developer who uses Codex CLI and wants to switch between several gateway models without re-running any tool.

**The problem:** Codex needs a provider block, a Responses API endpoint, and a model catalog file, and those are easy to get wrong by hand.

**The outcome:** Codex uses the gateway as its provider, and the chosen models appear in the built-in /model picker after one restart.

### Steps

1. Run `node bin/setup-gateway.mjs codex` and enter the Base URL and API key.
2. In interactive mode, tick the extra models you want in the multi-select list, or leave only the main model for a headless run.
3. Restart Codex once so it reads gateway-catalog.json at startup.
4. Open `/model` in Codex and choose a gateway model.
5. Run `node setup-gateway.mjs status` and check the Catalog line.

### Prompt to paste into your agent

```text
In the repo Sinholms/setup-gateway, run `node bin/setup-gateway.mjs codex --base-url <GATEWAY_BASE_URL> --api-key <API_KEY> --model <MODEL_ID> --yes`. Expect config.toml and gateway-catalog.json to be written in the Codex config directory. Verify that config.toml sets wire_api to responses and that model_catalog_json points to an existing gateway-catalog.json.
```

### Caveat

The gateway must serve the Responses API (/v1/responses), because Chat Completions only gateways will not work with Codex directly.

Risk, credentials: The key is stored as experimental_bearer_token in plaintext in config.toml, so keep the file private.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/sinholms-setup-gateway/set-up-codex-cli-model-picker/

## How to restore the last working config after a bad gateway change with Setup Gateway

Repo: [Sinholms/setup-gateway](https://github.com/Sinholms/setup-gateway) | Difficulty: Beginner | Time: 15 minutes | Basis: From the README

Bring back the most recent backup of Claude Code, OpenCode, or Codex config with one command.

**Who it is for:** A developer whose AI coding tool stopped working after a gateway, key, or model change and needs the previous config back quickly.

**The problem:** A wrong base URL or model in a config file blocks the tool, and manual recovery means finding the right file and hand-editing it.

**The outcome:** The previous config is restored, a backup of the broken state is kept, and the tool can run again.

### Steps

1. Run `node setup-gateway.mjs status` to see which base URL and model are active.
2. Run `node setup-gateway.mjs restore codex` to restore Codex, or replace codex with claude or opencode for the other tools.
3. In a terminal, pick the backup from the menu, or add --yes to take the newest one.
4. Run `node setup-gateway.mjs status` again to confirm the restored values.

### Prompt to paste into your agent

```text
In the repo Sinholms/setup-gateway, run `node setup-gateway.mjs restore <TOOL>` where <TOOL> is claude, opencode, or codex, adding --yes for the newest backup. Expect a message that the config was restored and that a backup of the previous state was made first. Verify by running `node setup-gateway.mjs status` and confirming the values match the backup.
```

### Caveat

Restore does not touch ~/.claude.json, so any approval suffix added there by an earlier setup stays in place.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/sinholms-setup-gateway/roll-back-broken-tool-config/

## How to run the built-in selftest in CI before publishing a release with Setup Gateway

Repo: [Sinholms/setup-gateway](https://github.com/Sinholms/setup-gateway) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Check the Setup Gateway pure functions in CI without touching real config files.

**Who it is for:** A maintainer or contributor of Setup Gateway who wants a fast pass or fail signal on every change before a release.

**The problem:** Changes to config writing or flag parsing can break setup for all three tools, and manual testing on real config is risky.

**The outcome:** CI gets an exit code of 0 or 1 from the selftest, and no real config file is modified during the check.

### Steps

1. Clone the repo and make sure Node 18 or newer is available.
2. Run `node setup-gateway.mjs --selftest` (or `npm run selftest`).
3. Check that the process exits with code 0.
4. Add the same command as a step in your CI workflow so it runs on every pull request. (inferred, check the README)

### Prompt to paste into your agent

```text
In the repo Sinholms/setup-gateway, run `node setup-gateway.mjs --selftest` and report the number of assertions and the exit code. Expect exit code 0 with no real config files changed. Verify that the exit code is 0 before approving any release step.
```

### Caveat

The README describes the selftest as running dozens of assertions, so treat the exit code as the pass signal, not a specific count.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/sinholms-setup-gateway/run-selftest-before-release/
