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

# CLIProxy API

> The routed CLIProxy workspace for OAuth providers, variants, routing, and upstream management

# CLIProxy API Integration

CCS uses [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) by
default, with an opt-in
[CLIProxyAPIPlus community fork](https://github.com/kaitranntt/CLIProxyAPIPlus)
for plus-only providers. In the current CCS UI, that capability is split
across **three routes**, not one generic page.

## Current Surface Map

| Route | What lives there | Use it when |
| - | - | - |
| `/cliproxy` | OAuth overview workspace | provider status, accounts, advanced variants, routing, account actions |
| `/cliproxy/ai-providers` | AI Providers workspace | API-key and connector routes that belong inside CLIProxy |
| `/cliproxy/control-panel` | embedded control panel | upstream management-center features that CCS does not re-skin |

## OAuth Overview Workspace

> [tab] Dark Theme
>
> ![CLIProxy overview workspace](https://mintcdn.com/ccs-7e541244/ZIh-b3XKOoSIE-qm/assets/screenshots/cliproxyapi.webp?fit=max\&auto=format\&n=ZIh-b3XKOoSIE-qm\&q=85\&s=495c3393af9cbe0b91c21ec688200f8e)

> [tab] Light Theme
>
> ![CLIProxy overview workspace in light theme](https://mintcdn.com/ccs-7e541244/ZIh-b3XKOoSIE-qm/assets/screenshots/cliproxyapi-light.webp?fit=max\&auto=format\&n=ZIh-b3XKOoSIE-qm\&q=85\&s=ffd2bddf6f4ac0f563f0914dd8cca8f6)

The `/cliproxy` route is the main CCS-owned control surface. It includes:

* a provider rail for authenticated OAuth providers
* a variant list for CCS-managed provider variants
* a proxy status widget and backend label
* `Add Account` as the primary account connection flow
* `Advanced Variant` for separate runtime/profile variants
* provider editors for accounts, models, targets, and routing
* deep links such as `?provider=claude` and `?action=auth` for focused flows

## Supported OAuth Providers

| Provider | Status | Notes |
| - | - | - |
| Claude | OAuth | Anthropic Claude with quota support |
| Gemini | OAuth | Google Gemini via OAuth |
| Codex | OAuth | OpenAI Codex routing |
| xAI (Grok) | OAuth | device-code OAuth; canonical ID `xai`, CLI alias `grok` |
| Antigravity | OAuth | multi-account routing |
| GitHub Copilot (deprecated) | OAuth | Compatibility account routing with quota support |
| Kiro | OAuth | AWS Builder ID / IDC-driven Kiro access |
| iFlow | OAuth | alternative AI routing |
| Kimi | OAuth | Moonshot Kimi OAuth-backed routing |
| Cursor | OAuth | browser-driven polling flow via CLIProxy |
| GitLab Duo | OAuth / PAT | browser OAuth or PAT login on the same shortcut |
| CodeBuddy | OAuth | browser-driven polling flow via CLIProxy |
| Kilo AI | OAuth | device-code flow through CLIProxy |
| Qoder | OAuth | device-code flow through CLIProxy |

### Quota-Supported Providers

`agy` · `claude` · `codex` · `gemini`

Deprecated compatibility provider: `ghcp`

### Backend Requirements

CCS registers **15 CLIProxy providers** today; **14** support account linking.
Qwen is the exception because the bundled runtime does not expose Qwen OAuth
account linking. Not every linkable provider works on both backend binaries.

* `original` is the default backend and tracks `router-for-me/CLIProxyAPI`
* `plus` downloads the maintained `kaitranntt/CLIProxyAPIPlus` fork and
  migrates legacy deleted-upstream Plus installs safely to the original backend
* The embedded control panel follows the backend: `original` uses upstream
  CPAMC, while `plus` uses the maintained
  `kaitranntt/Cli-Proxy-API-Management-Center` dashboard fork
* Works on `original` or `plus`: `agy`, `claude`, `codex`, `gemini`, `iflow`,
  `kimi`, `xai`
* Requires `plus`: `codebuddy`, `cursor`, `gitlab`, deprecated `ghcp`
  compatibility, `kilo`, `kiro`, and `qoder`

![Sanitized CCS proxy settings showing remote mode and fallback controls](https://mintcdn.com/ccs-7e541244/eI9u5E9n1MjkuQlm/assets/remote-proxy-settings.png?fit=max\&auto=format\&n=eI9u5E9n1MjkuQlm\&q=85\&s=d9230b8b866e037e2b5418854ca3dae9)

The same backend choice is reflected in the dashboard proxy settings. Keep
fallback enabled when you need remote proxy convenience without making local
launches depend on a single unavailable upstream. Advanced users can override
the generated CPAMC source with `cliproxy.management_panel_repository`.

## Model Catalogs And Pickers

CCS treats CLIProxy management model definitions as the primary catalog source.
The dashboard resolves model metadata in this order:

1. live CLIProxy management catalog
2. cached catalog snapshot
3. static CCS fallback catalog

That keeps the overview workspace usable even when the proxy is briefly
unavailable.

The provider editor's **Model Mapping** section exposes Default, Fable
(Frontier), Opus, Sonnet, and Haiku slots. Fable writes
`ANTHROPIC_DEFAULT_FABLE_MODEL`; leave it empty to keep Claude Code's native
Fable resolution. A mapped Fable model participates in the existing extended
context control when its catalog entry supports extended context.

The **catalog-sync subset is currently 11 providers**:

`agy` · `claude` · `codex` · `gemini` · `iflow` · `kimi` · `kiro` · `qoder`
· `qwen` · `xai`

Deprecated compatibility provider: `ghcp`

The newer auth-capable providers (`cursor`, `gitlab`, `codebuddy`, `kilo`) are
still current and supported, but they do not yet participate in the same local
catalog-sync pipeline.

```bash theme={null}
ccs cliproxy catalog
ccs cliproxy catalog refresh
ccs cliproxy catalog reset
```

After a CLIProxyAPI or CLIProxyAPIPlus release, run `ccs cliproxy --latest`
to update the local backend binary, then `ccs cliproxy catalog refresh` to
refresh dashboard model pickers and the local catalog cache.

## Routing Strategy

CCS exposes the proxy-wide routing strategy directly instead of inferring it
from account mix.

| Strategy | Behavior | Good fit |
| - | - | - |
| `round-robin` | spread requests across matching healthy accounts | even usage and predictable distribution |
| `fill-first` | drain one healthy account before touching backups | keep backup accounts cold until needed |

CCS keeps `round-robin` as the default until you change it explicitly.

```bash theme={null}
ccs cliproxy routing
ccs cliproxy routing explain
ccs cliproxy routing set fill-first
ccs cliproxy routing set round-robin
```

## Request Retry

The routing card also exposes global **Auto-retry** controls for the request
retry count and maximum retry interval. Both values must be non-negative safe
integers. The default `0` / `0` disables retrying; the interval is measured in
seconds. CLIProxy retries transient `403`, `408`, `500`, `502`, `503`, and `504`
responses, so enable this deliberately: retrying `403` responses can consume
additional quota in multi-account pools.

Local and remote proxy modes apply these controls differently:

* **Local:** CCS persists `cliproxy.retry`, regenerates the local CLIProxy
  configuration, and attempts to apply the values to the running proxy. If the
  live update fails, CCS reports a config-only result; the persisted values
  remain ready for the next proxy start.
* **Remote:** CCS applies the values through the remote CLIProxy management API,
  which persists them remotely. It does not write these values to the local CCS
  configuration.

This setting is separate from Account Pools' `max-retry-credentials`:
`request-retry` repeats a request after transient responses, while
`max-retry-credentials` caps how many credentials a pool tries for one request.

## Cross-Model Fallback Chains

When running high-volume autonomous workflows across upstream providers, backend rate limits (`429`) or balance exhaustion (`402`) can stall sessions even when alternative providers are healthy.

CCS supports configuring ordered **fallback chains** under `cliproxy.fallback_chain` in `~/.ccs/config.yaml`. When a terminal exhaustion event occurs on the primary candidate, the proxy automatically fails over through the ordered list of candidates.

### Configuration

```yaml theme={null}
cliproxy:
  fallback_chain:
    "codex:gpt-5.6-sol":
      candidates:
        - provider: "codex"
          model: "gpt-5.6-sol"
        - provider: "grok"
          model: "grok-beta"
        - provider: "claude"
          model: "claude-sonnet-4"
      sticky_primary: true
      exhaustion_cooldown: "15m"
```

### Parameters

| Setting | Type | Description |
| - | - | - |
| `candidates` | Array | Ordered sequence of `{ provider, model }` targets to attempt. |
| `sticky_primary` | Boolean | When `true`, fresh requests always attempt candidate 0 if healthy, rather than staying locked onto a fallback target. Defaults to `true`. |
| `exhaustion_cooldown` | String | Duration string (e.g. `15m`, `1h`) specifying how long an exhausted provider remains on cooldown before attempting recovery. Defaults to `15m`. |

### Failover Triggers & Invariants

* **Terminal Exhaustion (`402` & `429`):** Triggered when an entire provider credential pool is exhausted (all accounts on cooldown, usage limits reached, or quota zero).
* **Thinking Envelope Preservation:** Reasoning blocks and thinking parameters (`max_thinking_tokens`, `reasoning_effort`, `thinking: { type: "adaptive" }`) are automatically adapted across heterogeneous model architectures (e.g. OpenAI responses translated to Claude thinking envelopes).
* **Transient Errors Handled by Retry:** Transient network blips or short-term rate limits (`Retry-After <= 10s`) remain handled within the provider's active pool rather than immediately triggering a cross-provider failover.

## AI Providers Workspace

`/cliproxy/ai-providers` is now the dedicated home for non-OAuth upstreams that
still belong to the proxy layer.

Use it for:

* API-key families such as Gemini, Codex, Claude-compatible, and Vertex routes
* named OpenAI-compatible connectors
* advanced route composition with prefixes, proxy overrides, headers, and model aliases

Use [API Profiles](https://docs.ccs.kaitran.ca/providers/concepts/api-profiles.md) instead when you want a
CCS-native profile with its own `.settings.json`.

## Control Panel Embed

`/cliproxy/control-panel` embeds the upstream management center inside the CCS
dashboard shell.

* **Local mode** reverse-proxies `management.html` through the dashboard server to avoid cross-origin and port issues
* **Remote mode** uses the saved remote proxy config and bootstraps auth into the iframe when a management token is available

When you open the upstream management center directly (its `management.html`
login screen), it asks for a **Management Key**. The default is `ccs`. CCS
surfaces the Control Panel URL and a masked login key in `ccs cliproxy status`
and `ccs cliproxy start`. Run `ccs tokens --show` when you intentionally need
to reveal the full key.

Use this page when the upstream management center already exposes the exact
operation you need and CCS has intentionally chosen not to duplicate it.

## Target Metadata

Variants on the overview route can carry a CCS `target`:

| Target | CLI | Meaning |
| - | - | - |
| `claude` | Claude Code | default target |
| `droid` | Factory Droid | alternate runtime for compatible flows |

```bash theme={null}
ccs cliproxy create my-droid --provider gemini --target droid
ccs cliproxy edit my-droid --target droid
```

The target is CCS metadata layered on top of CLIProxy-managed routing.

## Quick Start

```bash theme={null}
ccs config
# Sidebar -> CLIProxy
```

Start on `/cliproxy` for OAuth-backed providers. Move to
`/cliproxy/ai-providers` when you need API-key or connector routes. Open
`/cliproxy/control-panel` when you need the upstream management-center surface.

## Related

* [AI Providers Workspace](https://docs.ccs.kaitran.ca/features/proxy/ai-providers.md)
* [CLIProxy Sync](https://docs.ccs.kaitran.ca/features/proxy/cliproxy-sync.md)
* [Remote Proxy](https://docs.ccs.kaitran.ca/features/proxy/remote-proxy.md)
* [Dashboard Overview](https://docs.ccs.kaitran.ca/features/dashboard/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.