# 4.4 Usage Statistics

## Overview

The usage statistics feature records and analyzes API request data, helping you:

- Understand API usage patterns
- Estimate cost expenditure
- Analyze usage patterns
- Troubleshoot issues

Starting from v3.13.0, usage data comes from two sources:

| Data Source                     | Coverage                                  | Proxy Interception Required? |
| ------------------------------- | ----------------------------------------- | ---------------------------- |
| **Proxy request log**           | All requests forwarded through the proxy | Yes                          |
| **CLI session log** (new in v3.13) | Claude / Codex / Gemini session history | No                           |

- **Codex sessions**: Switched to **precise parsing** based on JSONL session logs, replacing the previous estimation; model names are normalized for consistent pricing lookup
- **Gemini sessions**: Synced precisely from Gemini CLI session logs
- **Claude sessions**: Also supports direct usage import from session logs
- The usage panel supports **per-app filtering** (Claude / Codex / Gemini) so data from different apps does not mix

## Prerequisites

Depending on which data source you use, the prerequisites differ:

**Proxy request log** (covers all apps and all proxy requests):

1. Proxy service started
2. App takeover enabled
3. Log recording enabled

**CLI session log** (new in v3.13, no proxy required):

1. The corresponding app (Claude / Codex / Gemini) is enabled in CC Switch
2. The corresponding CLI has session history files
3. CC Switch periodically scans session directories and imports usage data

## Open Usage Statistics

Settings > Usage Tab

## Statistics Overview

### Summary Cards

Key metrics displayed at the top of the page:

| Metric | Description |
|--------|-------------|
| Total Requests | Total number of requests in the time period |
| Total Tokens | Total input + output tokens |
| Estimated Cost | Cost calculated based on pricing configuration |
| Success Rate | Percentage of successful requests |

### Time Range

Select the time range for statistics:

| Option | Range |
|--------|-------|
| Today | From 00:00 today to now |
| Last 7 Days | Past 7 days |
| Last 30 Days | Past 30 days |

![image-20260108011730105](../../assets/image-20260108011730105.png)

## Trend Charts

### Request Trend

Line chart showing the trend of request counts:

- X-axis: Time
- Y-axis: Request count
- Viewable by hour/day
- Supports zoom and drag

### Token Trend

Shows token usage trends:

- Input Tokens (blue) - Prompt content sent by the user
- Output Tokens (green) - Response content generated by AI
- Cache Creation Tokens (orange) - Tokens consumed when first creating cache
- Cache Hit Tokens (purple) - Tokens saved by reusing cache
- Cost (red dashed line, right Y-axis) - Estimated cost

> **Cache Token explanation**: Anthropic API supports Prompt Caching. Creating cache incurs a higher fee (typically 1.25x input price), but subsequent cache hits only charge 0.1x, significantly reducing costs for repeated requests.

### Time Granularity

- **Today**: Displayed by hour (24 data points)
- **7 Days/30 Days**: Displayed by day



![image-20260108011742847](../../assets/image-20260108011742847.png)

## Detailed Data

Three data tabs at the bottom of the page:

### Request Logs

Detailed record of each request:

| Field | Description |
|-------|-------------|
| Time | Request time |
| Provider | Provider name used |
| Model | Requested model (billing model) |
| Input Tokens | Number of input tokens |
| Output Tokens | Number of output tokens |
| Cache Read | Cache hit token count |
| Cache Creation | Cache creation token count |
| Total Cost | Estimated cost (USD) |
| Timing Info | Request duration, time to first token, streaming/non-streaming |
| Status | HTTP status code |

#### Timing Information

The timing info column displays multiple badges:

| Badge | Description | Color Rules |
|-------|-------------|-------------|
| Total Duration | Total request time (seconds) | <=5s green, <=120s orange, >120s red |
| First Token | Time to first token in streaming requests | <=5s green, <=120s orange, >120s red |
| Stream/Non-stream | Request type | Streaming blue, non-streaming purple |

#### View Details

Click a request row to view detailed information:

- Complete request parameters
- Response content summary
- Error messages (if failed)

#### Filter Logs

Supports filtering by the following criteria:

| Filter | Options |
|--------|---------|
| App Type | All / Claude / Codex / Gemini |
| Status Code | All / 200 / 400 / 401 / 429 / 500 |
| Provider | Text search |
| Model | Text search |
| Time Range | Start time - End time (datetime picker) |

Action buttons:
- **Search**: Apply filter criteria
- **Reset**: Restore defaults (past 24 hours)
- **Refresh**: Reload data

![image-20260108011859974](../../assets/image-20260108011859974.png)

### Provider Statistics

Statistics grouped by provider:

| Field | Description |
|-------|-------------|
| Provider | Provider name |
| Requests | Total requests for this provider |
| Successes | Number of successful requests |
| Failures | Number of failed requests |
| Success Rate | Success percentage |
| Total Tokens | Total token usage |
| Estimated Cost | Cost for this provider |

![image-20260108011907928](../../assets/image-20260108011907928.png)

### Model Statistics

Statistics grouped by model:

| Field | Description |
|-------|-------------|
| Model | Model name |
| Requests | Total requests for this model |
| Input Tokens | Total input tokens |
| Output Tokens | Total output tokens |
| Avg Latency | Average response time |
| Estimated Cost | Cost for this model |

![image-20260108011915381](../../assets/image-20260108011915381.png)

## Pricing Configuration

### Open Pricing Configuration

Settings > Advanced > Pricing Configuration

### Configure Model Prices

Set prices for each model (per million tokens):

| Field | Description |
|-------|-------------|
| Model ID | Model identifier (e.g., claude-3-sonnet) |
| Display Name | Custom display name |
| Input Price | Price per million input tokens |
| Output Price | Price per million output tokens |
| Cache Read Price | Price per million cache hit tokens |
| Cache Creation Price | Price per million cache creation tokens |

### Model ID Normalization Rules

Before matching pricing, CC Switch normalizes the requested model ID:

- Remove everything before the last `/`
- Remove everything after `:`
- Replace `@` with `-`

When adding pricing entries, enter the normalized Model ID rather than the full raw model name from the request.

| Raw model name | Model ID to enter | Note |
|-------|-------------------|------|
| `stepfun-ai/step-3.5-flash` | `step-3.5-flash` | Removes the provider prefix |
| `moonshotai/kimi-k2-0905:exa` | `kimi-k2-0905` | Removes the prefix and the `:` suffix |
| `gpt-5.2-codex@low` | `gpt-5.2-codex-low` | Replaces `@` with `-` |

### Operations

- **Add**: Click the "Add" button to add model pricing
- **Edit**: Click the edit icon at the end of the row to modify
- **Delete**: Click the delete icon at the end of the row to remove

![image-20260108011933565](../../assets/image-20260108011933565.png)

### Preset Prices

CC Switch includes preset official prices for common models (per million tokens). v3.13.0 corrects **CNY → USD pricing** for several models and adds previously missing model definitions; it also fixes **MiniMax plan quota math** and the **0% → 100% usage progress** display, making cost estimates and plan progress more accurate.

**Claude Series (USD)**:

| Model | Input | Output | Cache Read | Cache Creation |
|-------|-------|--------|------------|----------------|
| **Claude 4.5 Series** | | | | |
| claude-opus-4-5 | $5 | $25 | $0.50 | $6.25 |
| claude-sonnet-4-5 | $3 | $15 | $0.30 | $3.75 |
| claude-haiku-4-5 | $1 | $5 | $0.10 | $1.25 |
| **Claude 4 Series** | | | | |
| claude-opus-4 | $15 | $75 | $1.50 | $18.75 |
| claude-opus-4-1 | $15 | $75 | $1.50 | $18.75 |
| claude-sonnet-4 | $3 | $15 | $0.30 | $3.75 |
| **Claude 3.5 Series** | | | | |
| claude-3-5-sonnet | $3 | $15 | $0.30 | $3.75 |
| claude-3-5-haiku | $0.80 | $4 | $0.08 | $1.00 |

**OpenAI Series / Codex (USD)**:

| Model | Input | Output | Cache Read |
|-------|-------|--------|------------|
| **GPT-5.2 Series** | | | |
| gpt-5.2 | $1.75 | $14 | $0.175 |
| **GPT-5.1 Series** | | | |
| gpt-5.1 | $1.25 | $10 | $0.125 |
| **GPT-5 Series** | | | |
| gpt-5 | $1.25 | $10 | $0.125 |

> Note: Codex presets include low/medium/high variants with prices identical to the base model.

**Gemini Series (USD)**:

| Model | Input | Output | Cache Read |
|-------|-------|--------|------------|
| **Gemini 3 Series** | | | |
| gemini-3-pro-preview | $2 | $12 | $0.20 |
| gemini-3-flash-preview | $0.50 | $3 | $0.05 |
| **Gemini 2.5 Series** | | | |
| gemini-2.5-pro | $1.25 | $10 | $0.125 |
| gemini-2.5-flash | $0.30 | $2.50 | $0.03 |

**Chinese Provider Models**:

> Note: Currency follows each provider's official pricing page. StepFun is currently listed in USD.

| Model | Input | Output | Cache Read |
|-------|-------|--------|------------|
| **StepFun** | | | |
| step-3.5-flash | $0.10 | $0.30 | $0.02 |
| **DeepSeek** | | | |
| deepseek-v3.2 | ¥2.00 | ¥3.00 | ¥0.40 |
| deepseek-v3.1 | ¥4.00 | ¥12.00 | ¥0.80 |
| deepseek-v3 | ¥2.00 | ¥8.00 | ¥0.40 |
| **Kimi (Moonshot)** | | | |
| kimi-k2-thinking | ¥4.00 | ¥16.00 | ¥1.00 |
| kimi-k2 | ¥4.00 | ¥16.00 | ¥1.00 |
| kimi-k2-turbo | ¥8.00 | ¥58.00 | ¥1.00 |
| **MiniMax** | | | |
| minimax-m2.1 | ¥2.10 | ¥8.40 | ¥0.21 |
| minimax-m2.1-lightning | ¥2.10 | ¥16.80 | ¥0.21 |
| **Others** | | | |
| glm-4.7 | ¥2.00 | ¥8.00 | ¥0.40 |
| doubao-seed-code | ¥1.20 | ¥8.00 | ¥0.24 |
| mimo-v2-flash | Free | Free | - |

### Custom Prices

If using proxy services, prices may differ:

1. Click the "Edit" button
2. Modify prices
3. Save

## FAQ

### Statistics Data Is Empty

Check:
- Is the proxy service running
- Is app takeover enabled
- Is log recording enabled
- Have requests been going through the proxy

### Cost Estimates Are Inaccurate

Possible causes:
- Pricing configuration doesn't match actual prices
- Using a proxy service with special pricing

Solutions:
- Update pricing configuration
- Refer to the provider's actual invoices

### Token Count Differs from Provider

CC Switch uses its own method to estimate token counts, which may slightly differ from the provider's calculation. Refer to the provider's invoice for authoritative numbers.
