> ## 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.

# Kimi Provider

> Moonshot AI K2/K2.5 models via OAuth (CLIProxy) or API key direct (km)

# Kimi Provider

CCS provides two distinct Kimi offerings:

| Command | Auth | Endpoint | Use Case |
| - | - | - | - |
| `ccs kimi` | OAuth via CLIProxy (device code) | `http://127.0.0.1:8317/api/provider/kimi` | Multi-account, no API key needed |
| `ccs km` | API key direct | `https://api.kimi.com/coding/` | Single API key, Kimi for Coding |

Provider aliases: `kimi`, `moonshot` both route to the same CLIProxy provider.

## Quick Start

```bash theme={null}
# OAuth mode (CLIProxy) — no API key needed
ccs kimi "explain this code"

# API preset mode — requires API key (Kimi for Coding)
ccs km "explain this code"

# List accounts (OAuth mode)
ccs kimi --accounts

# Switch account
ccs kimi --use work
```

## Authentication

### `ccs kimi` — OAuth Mode (CLIProxy)

**1. Trigger Login**

Run `ccs kimi --kimi-login` — device code displayed in terminal

**2. Activate Device**

Visit the URL shown and enter the device code (no callback port needed)

**3. Token Cached**

OAuth token saved to `~/.ccs/cliproxy/auth/kimi-{email}.json`

**4. Auto Refresh**

CLIProxy backend manages token refresh automatically

**Device Code Flow:** Polling-based authentication — no local callback server required. Works in headless/server environments.

### `ccs km` — API Key Mode (Kimi for Coding)

**1. Get API Key**

Obtain a `sk-...` key from Moonshot AI platform

**2. Configure**

Run `ccs km` — prompted for API key on first use

**3. Thinking Always On**

All requests use extended thinking by default

> [!NOTE]
>
> `ccs km` connects directly to `https://api.kimi.com/coding/`. Default model: `kimi-for-coding`. The `--preset kimi` flag auto-maps to `km` for backward compatibility.

## Multi-Account Support

> [tab] Add Account
>
> ```bash theme={null}
> # Add second Kimi account (preserves existing)
> ccs kimi --kimi-login --add
>
> # Auto-nicknamed from email prefix
> ```

> [tab] List Accounts
>
> ```bash theme={null}
> ccs kimi --accounts
>
> # Output:
> # Available Kimi accounts:
> # * personal (user@email.com) - default
> #   work (work@email.com)
> ```

> [tab] Switch Account
>
> ```bash theme={null}
> # Switch default account
> ccs kimi --use work
>
> # Rename current account
> ccs kimi --nickname personal
> ```

**Account Registry:** `~/.ccs/cliproxy/accounts.json` — aliases `kimi` and `moonshot` both map to the same provider.

## Model Configuration

### Available Models

#### `ccs kimi` (CLIProxy OAuth)

| Model | Context | Notes |
| - | - | - |
| `kimi-k2.5` | 262K | Default — latest multimodal |
| `kimi-k2-thinking` | — | Extended reasoning |
| `kimi-k2` | — | Flagship coding model |

#### `ccs km` (API key direct)

| Model | Notes |
| - | - |
| `kimi-for-coding` | Default model for `km` |

**Thinking budget:** 1K–32K tokens, dynamic and zero allowed.

**Vision:** Configurable via `vision-model` placeholder in settings.

### Settings Template

Settings saved to `~/.ccs/km.settings.json` from `base-km.settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.kimi.com/coding/",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_KIMI_API_KEY_HERE",
    "ANTHROPIC_MODEL": "kimi-for-coding",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-for-coding",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-for-coding",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-for-coding"
  }
}
```

> [!NOTE]
>
> These env vars are injected automatically by CCS. Manual override is rarely needed.

## Commands Reference

```bash theme={null}
# Basic usage
ccs kimi "your prompt"
ccs km "your prompt"              # API preset

# Authentication
ccs kimi --kimi-login             # Trigger device code OAuth
ccs kimi --kimi-login --add       # Add second account
ccs kimi --logout                 # Clear tokens

# Account management
ccs kimi --accounts               # List all accounts
ccs kimi --use work               # Switch default account
ccs kimi --nickname personal      # Rename current account
```

## Troubleshooting

### Device Code Expired

**Symptom:** "Device code expired" error during login

**Solution:** Device codes have a short TTL. Re-run login and complete quickly:

```bash theme={null}
ccs kimi --logout
ccs kimi --kimi-login
```

### API Key Rejected (km mode)

**Symptom:** 401 errors when using `ccs km`

**Solution:** Verify key format (`sk-...`) and permissions on Moonshot AI platform.

> [!WARNING]
>
> API keys for `ccs km` are separate from OAuth tokens used by `ccs kimi`. Do not mix them.

### Wrong Account Active

**Symptom:** Unexpected account being used

**Solution:**

```bash theme={null}
# Check default (marked with *)
ccs kimi --accounts

# Switch default
ccs kimi --use work
```

## Storage Locations

| Path | Description |
| - | - |
| `~/.ccs/cliproxy/auth/kimi-*.json` | OAuth tokens (one per account) |
| `~/.ccs/cliproxy/accounts.json` | Account registry, nicknames |
| `~/.ccs/km.settings.json` | Kimi for Coding model config |

## Cost Information

| Model | Input/M | Output/M | Cache/M |
| - | - | - | - |
| `kimi-k2.5` | \$0.60 | \$3.00 | \$0.10 |
| `kimi-k2-thinking` | \$0.60 | \$2.50 | \$0.15 |
| `kimi-for-coding` | \$0.60 | \$2.50 | \$0.15 |
| `kimi-k2` | \$0.60 | \$2.50 | \$0.15 |

## Next Steps

> [card] [Multi-Account Setup](https://docs.ccs.kaitran.ca/providers/concepts/overview.md#multi-account-management)
>
> Manage multiple Kimi accounts

> [card] [API Preset (km)](https://docs.ccs.kaitran.ca/providers/concepts/overview.md#api-presets)
>
> Configure direct API key access

> [card] [Remote Proxy](https://docs.ccs.kaitran.ca/features/proxy/remote-proxy.md)
>
> Connect to external CLIProxy server

> [card] [All Providers](https://docs.ccs.kaitran.ca/providers/concepts/overview.md)
>
> Explore other supported providers


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