> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcore.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Your Claude / Codex Subscription

> Point CORE at your Claude Max, ChatGPT Codex, Antigravity, or xAI Grok subscription — no API credits needed.

If you already pay for Claude Max, a ChatGPT plan that includes Codex, Google Antigravity, or xAI Grok, you can point CORE at your subscription instead of buying separate API credits. The CoreBrain Gateway includes a subscription proxy (CLIProxyAPI) that speaks OpenAI-compatible on the outside and translates to each subscription's native protocol on the inside.

<Warning>
  Subscription plans are licensed for **interactive** use. Providers can rate-limit or revoke tokens if they detect headless usage. Fine for personal self-host on a laptop or single VPS; risky if you're serving other users. When in doubt, use real API keys.
</Warning>

## The whole setup, four steps

### 1. Deploy the gateway

Pick one of [Railway, Docker, or native](/gateway/setup). The gateway image bundles CLIProxyAPI, so nothing extra to install. On first boot it prints a public URL and a `gwk_...` security key.

### 2. Register the gateway in CORE

In the CORE webapp: **Sidebar → Gateways → + New gateway**. Paste the URL and security key.

### 3. Install the CLI and log in to your workspace

```bash theme={null}
npm install -g @redplanethq/corebrain
corebrain login
```

### 4. Log in to each subscription

One command per subscription. The CLI drives the OAuth flow end-to-end and lands tokens directly on the gateway.

```bash theme={null}
corebrain gateway llmproxy --login claude
corebrain gateway llmproxy --login codex
corebrain gateway llmproxy --login antigravity
corebrain gateway llmproxy --login xai
```

Two flow types depending on the provider:

* **Claude / Codex / Antigravity** — CLI prints an OAuth URL. Open it, approve, and the CLI's local server catches the redirect and forwards it to the gateway. Nothing to type back.
* **xAI** — CLI prints a URL **and a short code**. Open the URL, type the code on the page, done.

Add `--gateway <name-or-id>` if you have multiple gateways registered.

## Wire the proxy into CORE

In the CORE webapp, open **Workspace Settings → Models → API Keys**, click **+ Add API key**, choose **OpenAI**, and fill in:

* **Base URL** — `https://<your-gateway-host>/llmproxy/v1`
* **API key** — the same `COREBRAIN_GATEWAY_SECURITY_KEY` value from step 1

Then pick a model with the `openai/` prefix. Examples:

| Model                      | Routes to       |
| -------------------------- | --------------- |
| `openai/claude-sonnet-4-6` | Claude Max      |
| `openai/claude-opus-4-7`   | Claude Max      |
| `openai/gpt-5.5`           | ChatGPT / Codex |
| `openai/gemini-2.0-flash`  | Antigravity     |
| `openai/grok-2-latest`     | xAI             |

Get the exact list of available models by hitting the proxy's model endpoint:

```bash theme={null}
curl -s https://<your-gateway-host>/llmproxy/v1/models \
  -H "Authorization: Bearer <your-COREBRAIN_GATEWAY_SECURITY_KEY>" | jq
```

## When a token expires

Just re-run the same command:

```bash theme={null}
corebrain gateway llmproxy --login claude
```

CLIProxyAPI auto-rotates access tokens as long as the refresh token stays valid; when it doesn't, re-login. Tokens live on the gateway's persistent volume, so a container restart never blows them away.

## Structured outputs & tool calling

Under the hood, CORE routes structured-extraction calls (memory ingestion, label classification, etc.) via OpenAI-compatible **tool calling**. Claude's grammar-constrained sampling makes this reliable even for empty content — the model will call the tool with empty arrays rather than respond with prose refusals like "there's nothing to extract."

## Alternatives

The steps above use the built-in [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) inside the gateway. Other options exposing an OpenAI-compatible `/v1/chat/completions` surface work with the same BYOK wire-up:

* **[Vercel AI Gateway](https://vercel.com/docs/ai-gateway/coding-agents/claude-code)** — first-party pass-through for Claude Max via `ANTHROPIC_BASE_URL`. No self-hosting.
* **[ai-cli-proxy-api](https://github.com/ben-vargas/ai-cli-proxy-api)** — variant that supports Factory and Amp CLIs alongside ChatGPT Plus/Pro and Claude Pro/Max.
