# claude-remap

Local API proxy with model name remapping. Zero dependencies, pure Node.js.

Point your AI tools at `localhost`, use custom model names — the proxy rewrites them to the real upstream model and rewrites responses back. Supports both OpenAI (`Authorization: Bearer`) and Claude (`x-api-key`) auth formats, auto-detected per request.

## Install & Run

```bash
npx claude-remap \
  -t https://your-relay.com \
  -k sk-your-api-key \
  -m my-model:real-model-name
```

## What It Does

```
Your Tool                    claude-remap                  Relay Station
─────────                    ────────────                  ─────────────
model: "my-gpt4"    →    rewrites to "deepseek-chat"   →   upstream API
                     ←    rewrites back to "my-gpt4"    ←   response
```

- Proxies all requests from `localhost` to the target relay station
- Replaces the `model` field in request JSON with the mapped real name
- Rewrites the `model` field in responses (including SSE streams) back to your alias
- Injects your API key automatically — clients don't need a real key
- Auto-detects Claude vs OpenAI auth format

## Options

| Flag | Env Var | Default | Description |
|------|---------|---------|-------------|
| `-t, --target <url>` | `PROXY_TARGET` | — | Relay station base URL (required) |
| `-k, --key <key>` | `PROXY_KEY` | — | API key, injected into every request |
| `-p, --port <port>` | `PROXY_PORT` | `9960` | Local port |
| `-m, --map <a:b>` | — | — | Model alias mapping, repeatable |
| `-v, --verbose` | — | — | Log upstream details |

## Examples

### Single model remap

```bash
npx claude-remap \
  -t https://api.relay.com \
  -k sk-xxxx \
  -m gpt4:deepseek-chat
```

### Multiple models

```bash
npx claude-remap \
  -t https://api.relay.com \
  -k sk-xxxx \
  -m claude-sonnet:deepseek-v4-pro \
  -m claude-opus:deepseek-reasoner \
  -m gpt4:qwen-max
```

### Use with Claude Code

1. Start the proxy:

```bash
npx claude-remap \
  -t https://your-relay.com \
  -k sk-real-key \
  -m claude-deepseek-v4-pro:deepseek-v4-pro
```

2. Configure Claude Code to use `http://localhost:9960` as API base URL, with any placeholder API key.

3. Select model `claude-deepseek-v4-pro` — it hits `deepseek-v4-pro` on the relay station.

### Env vars (no key in shell history)

```bash
export PROXY_TARGET=https://api.relay.com
export PROXY_KEY=sk-xxxx
npx claude-remap -m my-model:real-model
```

## Requirements

- Node.js >= 18

## License

MIT
