@axisapi/statusline

English | 简体中文
A Claude Code status line tool built for the AxisAPI AI aggregation platform. It automatically detects your AxisAPI provider from environment variables, Claude Code settings, or CCSwitch, then configures Claude Code’s statusLine command for you.
Inspired by Haleclipse/CCometixLine.
Features
- Auto-detects AxisAPI provider configuration from env vars, Claude Code settings, CCSwitch JSON files, and CCSwitch SQLite data.
- Writes Claude Code
statusLine.command = "axisapi-statusline" automatically during initialization.
- Shows balance, today’s usage, channel/provider, model, and context usage in a concise status line.
- Caches successful API responses locally for fast rendering and falls back to stale cache if the API request fails.
- Provides
doctor, sync, config, and clear-cache commands for setup and troubleshooting.
Preview
Full status line
AxisAPI ¥23.80 · Today ¥1.24 · Claude-A · Sonnet 4.5 · 32%
Shown when local AxisAPI config exists and the backend API returns account data successfully.
| Segment |
Meaning |
AxisAPI |
Platform name returned by the backend, or the configured platform name. |
¥23.80 |
Current account balance, formatted with the returned currency. |
Today ¥1.24 |
Today’s usage/cost. |
Claude-A |
Current channel or provider returned by the backend. |
Sonnet 4.5 |
Model display name returned by the backend, or the model detected from Claude Code. |
32% |
Claude Code context window usage percentage. |
API unavailable, cache/config available
AxisAPI ¥23.80 · Today ¥1.24 · Claude-A · Sonnet 4.5 · 32%
If the live API request fails but a previous successful response is cached, the status line falls back to stale cache data so the display remains useful.
| Segment |
Meaning |
AxisAPI ¥23.80 |
Cached platform and balance from the last successful API response. |
Today ¥1.24 |
Cached usage/cost from the last successful API response. |
Claude-A |
Cached channel/provider value. |
Sonnet 4.5 |
Cached or Claude Code-detected model display name. |
32% |
Current Claude Code context usage, when provided by Claude Code. |
Config exists, but no API data is available
AxisAPI · Sonnet 4.5 · 32%
Shown when AxisAPI local config exists, but neither live API data nor cached API data is available.
| Segment |
Meaning |
AxisAPI |
Default platform label. |
Sonnet 4.5 |
Model detected from Claude Code input or local config. |
32% |
Claude Code context window usage percentage. |
Running through a local CCSwitch proxy
AxisAPI · Sonnet 4.5 · 32% · via CCSwitch
Shown when ANTHROPIC_BASE_URL points to a local proxy and no live/cached API data is available.
| Segment |
Meaning |
via CCSwitch |
The current Claude Code request appears to be routed through a local CCSwitch proxy. |
Not initialized yet
AxisAPI · Sonnet 4.5 · 32% · Not initialized
Shown when ~/.axisapi/statusline.json has not been created yet.
| Segment |
Meaning |
Not initialized |
Run axisapi-statusline init to detect/write AxisAPI status line config. |
Requirements
- Node.js 18+
- Claude Code
- An AxisAPI-compatible provider/API key
Installation
Install globally from npm:
npm install -g @axisapi/statusline
Package page: @axisapi/statusline on npm
Quick Start
Initialize the status line:
axisapi-statusline init
If provider detection fails, pass the provider manually:
axisapi-statusline init --base-url https://axisapi.cn --api-key sk-axis-xxxx --model claude-sonnet-4-5
Restart Claude Code after initialization. Claude Code will then call axisapi-statusline automatically when rendering the status line.
CLI Commands
axisapi-statusline # Render the status line; Claude Code calls this
axisapi-statusline init # Initialize local config and Claude Code statusLine
axisapi-statusline sync # Resync AxisAPI provider from env / Claude settings / CCSwitch
axisapi-statusline doctor # Check config, statusLine wiring, and API connectivity
axisapi-statusline config # Show local config with masked API key
axisapi-statusline clear-cache
Detection Order
axisapi-statusline init and axisapi-statusline sync resolve provider configuration in this order:
- Explicit CLI options:
--base-url, --api-key, --model
- Process environment variables
- Claude Code settings env blocks
- CCSwitch JSON configuration files
- CCSwitch SQLite database via
sql.js
A provider is accepted only when the base URL looks AxisAPI-related and the API key is usable.
Local Files
This CLI writes user-level configuration files:
| File |
Purpose |
~/.axisapi/statusline.json |
AxisAPI statusline config |
~/.axisapi/cache.json |
Short-lived API response cache |
~/.claude/settings.json |
Claude Code statusLine configuration |
~/.cc-switch/* |
Scanned for provider configuration when available |
Backend API Contract
The CLI calls:
GET /api/statusline/me
Authorization: Bearer <AxisAPI API Key>
Expected JSON:
{
"platform": "AxisAPI",
"balance": 23.8,
"currency": "CNY",
"todayCost": 1.24,
"channel": "Claude-A",
"modelDisplayName": "Sonnet 4.5"
}
Development
npm install
npm run check
npm link
axisapi-statusline init --base-url https://axisapi.cn --api-key sk-axis-test
axisapi-statusline doctor
Common scripts:
npm start # Run node ./bin/axisapi-statusline.js
npm run init # Run the init command
npm run doctor # Run diagnostics
npm run sync # Resync provider config
npm run pack:dry # Preview npm package contents
There is currently no test suite configured. Use npm run check plus focused manual CLI commands for validation.
Acknowledgements
- Thanks to CCometixLine for the inspiration and reference.
- Built for Claude Code users who route Claude traffic through AxisAPI-compatible providers.
License
MIT
评论