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

# AIHubMix CLI

> AIHubMix CLI is the official AIHubMix command-line tool: a single binary with zero dependencies. Query your account balance, manage API Keys, and view available models right from the terminal, with script- and AI Agent-friendly output.

**AIHubMix CLI** is the official AIHubMix command-line tool (executable `aihubmix`). Once installed, you can query your account balance, manage API Keys, and view available models from the terminal without opening the web console. It is a single binary — **no Python, Node, or Go required** — and installs with one command; every command supports JSON output, so it plugs straight into scripts, CI, and AI Agents (such as Claude Code).

**What it can do:**

* **Check balance**: Query your account balance and used quota in real time
* **Manage Keys**: Create, view, search, update, and delete API Keys
* **View models**: List the models available to the current token
* **Scriptable**: JSON output + stable exit codes, a natural fit for automation and AI Agents

<Info>
  **Don't mix up the two credentials**: The CLI signs in with a "System Access Token" (Manage Key, format `fd***`). Get it from the console at [console.aihubmix.com/setting](https://console.aihubmix.com/setting) by clicking "Generate System Access Token". It is used to **manage your account** and is not the same as the API Key (`sk-***`) you use to call models.
</Info>

<Tip>
  Looking for the older Python script (`aihubmix_cli.py`)? See [Retrieve Account Information via API](/en/api/Cli). This page is its next-generation replacement — simpler and faster.
</Tip>

## Installation

### One-Command Install (Recommended)

Copy the command for your system, paste it into your terminal, and run it to download the binary and automatically add it to `PATH`:

<CodeGroup>
  ```bash macOS / Linux theme={null}
  curl -fsSL https://raw.githubusercontent.com/AIhubmix/platfrom-cli/main/install.sh | sh
  ```

  ```powershell Windows PowerShell theme={null}
  irm https://raw.githubusercontent.com/AIhubmix/platfrom-cli/main/install.ps1 | iex
  ```
</CodeGroup>

After installation, **open a new terminal**, then run `aihubmix login` to get started.

<Info>
  You can also manually download the binary for your platform from [Releases](https://github.com/AIhubmix/platfrom-cli/releases) (Windows: `aihubmix_windows_amd64.exe`) and place it in a `PATH` directory; on Unix-like systems, run `chmod +x`.
</Info>

When needed, you can adjust install behavior with environment variables:

| Variable           | Description                                | Default                                                                          |
| ------------------ | ------------------------------------------ | -------------------------------------------------------------------------------- |
| `AIHUBMIX_VERSION` | Install a specific version (e.g. `v0.2.0`) | `latest`                                                                         |
| `AIHUBMIX_BIN_DIR` | Custom install directory                   | Unix: `/usr/local/bin` or `~/.local/bin`; Windows: `%LOCALAPPDATA%\aihubmix\bin` |

## Quick Start

Once logged in, all commands are available:

```bash theme={null}
# 1. Log in: opens a browser to the token generation page; paste your Manage Key (input is hidden)
aihubmix login

# 2. View current identity and balance
aihubmix whoami

# 3. View full account information
aihubmix me

# 4. List your API Keys
aihubmix keys list
```

## Command Reference

| Command                             | Purpose                                   |
| ----------------------------------- | ----------------------------------------- |
| `aihubmix login`                    | Log in (paste Manage Key)                 |
| `aihubmix logout`                   | Log out, clear local credentials          |
| `aihubmix whoami`                   | View current login identity and balance   |
| `aihubmix me`                       | View full account information and balance |
| `aihubmix models list`              | View currently available models           |
| `aihubmix keys list [--num N]`      | List API Keys                             |
| `aihubmix keys search <keyword>`    | Search Keys by keyword                    |
| `aihubmix keys get <id>`            | View details for a specific Key           |
| `aihubmix keys create [flags]`      | Create a new Key                          |
| `aihubmix keys update <id> [flags]` | Update a Key                              |
| `aihubmix keys delete <id>`         | Delete a Key                              |

<Tip>
  Add `--help` to any command to see its full flags, e.g. `aihubmix keys create --help`.
</Tip>

## Common Operations

### Managing API Keys

```bash theme={null}
# Create a Key with a $10 quota limit, restricted to specific models
aihubmix keys create -n prod-key -q 10 -m "gpt-4o,claude-3.5-sonnet"

# Create a Key with unlimited quota that never expires
aihubmix keys create -n ci-key -u

# Rename a Key (all other settings unchanged)
aihubmix keys update 123 -n new-name

# Disable a Key
aihubmix keys update 123 --status 0

# Delete a Key
aihubmix keys delete 123
```

Here `-q 10` sets a \$10 quota limit on the Key, and `-u` means unlimited quota. Deletion prompts for confirmation by default; add `--yes` to skip it in CI scenarios.

### Using with Scripts / AI Agents

The CLI is very automation-friendly and can be driven directly by CI, scripts, or AI Agents (such as Claude Code):

* **Login-free**: Pass a Manage Key via the `AIHUBMIX_TOKEN` environment variable or `--token` to skip interactive login (priority: `--token` > `AIHUBMIX_TOKEN` > config file).
* **JSON output**: Add `--json` (`-j`) to any command; normal results go to stdout and errors to stderr, making `jq` parsing easy.
* **Stable exit codes**: Scripts can branch on these to determine success or failure.

```bash theme={null}
# Drive with an env var and extract all Key names
AIHUBMIX_TOKEN=fd*** aihubmix keys list --json | jq '.data[].name'

# Query balance
AIHUBMIX_TOKEN=fd*** aihubmix whoami --json | jq -r '.balance'
```

Exit code meanings:

| Exit Code | Meaning                                                   |
| --------- | --------------------------------------------------------- |
| `0`       | Success                                                   |
| `1`       | General error (invalid arguments, business failure, etc.) |
| `2`       | Authentication failure (not logged in / invalid token)    |
| `3`       | Network / connection error                                |

## Global Flags

The following flags apply to all commands:

| Flag               | Short | Description                                           |
| ------------------ | ----- | ----------------------------------------------------- |
| `--token <token>`  | `-t`  | Pass a Manage Key directly (CI / scripting scenarios) |
| `--json`           | `-j`  | Output in JSON format                                 |
| `--base-url <url>` | `-b`  | Custom API URL (default `https://aihubmix.com`)       |
| `--no-color`       |       | Disable colored output                                |
| `--config <path>`  |       | Specify the config file path                          |
| `--version`        |       | Print version                                         |

## Configuration File

Login information is stored in `~/.aihubmix/config.json` (Windows: `%USERPROFILE%\.aihubmix\config.json`), with permissions tightened to **read/write by the current user only**. During login, the Manage Key is not echoed and not written to logs.

<Warning>
  Do not commit your Manage Key to a code repository or share it with others. If it leaks, regenerate it in the console; the old token is invalidated immediately.
</Warning>

## FAQ

**Do I need to install Python / Node / Go?**

No. The CLI is a single binary — download and use.

**What's the difference between a Manage Key and an API Key?**

The Manage Key (`fd***`) is used to manage your account (check balance, manage Keys) and is used by the CLI; the API Key (`sk-***`) is used to call models. They are generated in different places in the console and cannot be used interchangeably.

**Is Windows supported?**

Yes. Native binaries are provided for Windows, macOS, and Linux.

**How do I use it non-interactively in CI / scripts?**

Pass the Manage Key via the `AIHUBMIX_TOKEN` environment variable, combined with `--json` and exit codes — no need to run `aihubmix login`.

**What if I forget or leak my Manage Key?**

Regenerate it at [console.aihubmix.com/setting](https://console.aihubmix.com/setting); the old token is invalidated.

***

*Related docs: [Platform API · CliEndpoints](/en/api/CliEndpoints/get-self) · [Legacy Python Script](/en/api/Cli) · [AIHubMix Console](https://console.aihubmix.com)*

***

Last updated: 2026-06-22
