> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/clore.ai/clore.ai-eng-zh/kai-fa-zhe/cli-guide.md).

# CLI 参考

该 `clore` CLI 允许您直接从终端管理 Clore.ai GPU 市场——搜索 GPU、部署实例、SSH 登录并管理订单，无需编写任何代码。

***

## 安装

```bash
pip install clore-ai
```

这会同时安装 Python SDK 和 `clore` CLI 命令。

**要求：** Python 3.9+

***

## 配置

### 设置您的 API 密钥

从以下位置获取您的密钥 [Clore.ai 仪表板](https://clore.ai) → **API** 部分，然后配置：

```bash
clore config set api_key YOUR_API_KEY
```

这会将密钥保存到 `~/.clore/config.json`.

### 或使用环境变量

```bash
export CLORE_API_KEY=your_api_key_here
```

### 查看当前配置

```bash
# 显示所有配置
clore config show

# 获取特定值
clore config get api_key
```

***

## 命令

| 命令                                    | 说明           |
| ------------------------------------- | ------------ |
| `clore search`                        | 搜索 GPU 市场    |
| `clore deploy <server_id>`            | 创建新订单（租用服务器） |
| `clore orders`                        | 列出您的订单       |
| `clore cancel <order_id>`             | 取消订单         |
| `clore ssh <order_id>`                | SSH 登录到活动订单  |
| `clore wallets`                       | 显示钱包余额       |
| `clore servers`                       | 列出您托管的服务器    |
| `clore server-config <name>`          | 获取服务器配置      |
| `clore spot <server_id>`              | 查看服务器的现货市场   |
| `clore spot-price <order_id> <price>` | 设置现货价格       |
| `clore config set <key> <value>`      | 设置配置值        |
| `clore config get <key>`              | 获取配置值        |
| `clore config show`                   | 显示所有配置       |
| `clore --version`                     | 显示版本         |

***

## 详细用法

### `clore search`

使用过滤器和排序搜索 GPU 市场。

```bash
# 列出所有可用服务器（按价格排序，前 20）
clore search

# 按 GPU 型号过滤
clore search --gpu "RTX 4090"

# 按 GPU 和最高价格过滤
clore search --gpu "RTX 4090" --max-price 5.0

# 多 GPU 机架
clore search --min-gpu 4

# 按 GPU 数量排序，显示前 10
clore search --sort gpu --limit 10

# 组合过滤器
clore search --gpu "A100" --min-ram 128 --max-price 10.0 --sort price --limit 5
```

**选项：**

| 选项            | 类型  | 说明                               |
| ------------- | --- | -------------------------------- |
| `--gpu`       | 文本  | 按 GPU 型号过滤（例如 `"RTX 4090"`)      |
| `--min-gpu`   | 整数  | 最小 GPU 数量                        |
| `--min-ram`   | 浮点数 | 最小内存（GB）                         |
| `--max-price` | 浮点数 | 最高价格（美元/小时）                      |
| `--sort`      | 选项  | 排序方式： `price` （默认）， `gpu`, `ram` |
| `--limit`     | 整数  | 显示的最大结果数（默认：20）                  |

**示例输出：**

```
🔍 GPU 市场
┏━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ ID  ┃ GPU                             ┃ 数量  ┃ 内存 (GB) ┃ CPU                          ┃ 价格/小时 (USD) ┃ 地点     ┃
┡━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ 123 │ 1x NVIDIA GeForce RTX 4090      │     1 │    64.0  │ AMD Ryzen 9 5900X            │       $0.3200 │ 美国     │
│ 456 │ 2x NVIDIA GeForce RTX 4090      │     2 │   128.0  │ Intel Core i9-13900K         │       $0.5800 │ 德国     │
└─────┴─────────────────────────────────┴───────┴──────────┴──────────────────────────────┴───────────────┴──────────┘
显示 2 台服务器
```

***

### `clore deploy <server_id>`

创建新订单以租用 GPU 服务器。

```bash
# 按需订单并启用 SSH
clore deploy 123 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password MySecurePass123 \
  --port 22:tcp \
  --port 8888:http

# 现货订单
clore deploy 123 \
  --image cloreai/pytorch \
  --type spot \
  --currency bitcoin \
  --spot-price 0.000005 \
  --port 22:tcp

# 使用环境变量
clore deploy 123 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password MyPass123 \
  --port 22:tcp \
  --env WANDB_API_KEY=your_key \
  --env HF_TOKEN=your_token
```

**参数：**

| 参数          | 说明                           |
| ----------- | ---------------------------- |
| `server_id` | 要租用的服务器 ID（从 `clore search`) |

**选项：**

| 选项               | 类型  | 必填 | 说明                                         |
| ---------------- | --- | -- | ------------------------------------------ |
| `--image`        | 文本  | 是  | Docker 镜像（例如 `cloreai/ubuntu22.04-cuda12`) |
| `--type`         | 选项  | 是  | `on-demand` 或 `spot`                       |
| `--currency`     | 文本  | 是  | 支付货币（例如 `bitcoin`)                         |
| `--ssh-password` | 文本  | 否  | SSH 密码（字母数字，最多 32 个字符）                     |
| `--ssh-key`      | 文本  | 否  | SSH 公钥                                     |
| `--port`         | 文本  | 否  | 端口映射（可重复），格式： `PORT:PROTOCOL`              |
| `--env`          | 文本  | 否  | 环境变量（可重复），格式： `KEY=VALUE`                  |
| `--spot-price`   | 浮点数 | 否  | 现货订单的每日现货价格（现货订单必填）                        |

***

### `clore orders`

列出您正在进行的活跃订单。

```bash
# 活跃订单
clore orders

# 包括已完成/已过期的订单
clore orders --completed
```

**选项：**

| 选项            | 说明           |
| ------------- | ------------ |
| `--completed` | 包括已完成/已过期的订单 |

**示例输出：**

```
📦 我的订单
┏━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ 服务器 ID ┃ 类型      ┃ 状态   ┃ 镜像                             ┃ IP                      ┃
┡━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 38 │ 6         │ on-demand │ 活跃   │ cloreai/ubuntu22.04-cuda12        │ n1.c1.clorecloud.net    │
└────┴───────────┴───────────┴────────┴───────────────────────────────────┴─────────────────────────┘
总计：1 个订单
```

***

### `clore cancel <order_id>`

取消一个活动订单。

```bash
# 取消订单
clore cancel 38

# 带问题报告的取消
clore cancel 38 --issue "GPU was overheating"
```

**参数：**

| 参数         | 说明        |
| ---------- | --------- |
| `order_id` | 要取消的订单 ID |

**选项：**

| 选项        | 说明          |
| --------- | ----------- |
| `--issue` | 取消原因 / 问题报告 |

***

### `clore ssh <order_id>`

自动通过 SSH 连接到运行中的订单。CLI 会从您的订单详情解析主机名和端口。

```bash
# 以 root 身份连接（默认）
clore ssh 38

# 以其他用户连接
clore ssh 38 --user ubuntu
```

**参数：**

| 参数         | 说明        |
| ---------- | --------- |
| `order_id` | 要连接的订单 ID |

**选项：**

| 选项       | 默认     | 说明      |
| -------- | ------ | ------- |
| `--user` | `root` | SSH 用户名 |

***

### `clore wallets`

显示您的钱包余额和充值地址。

```bash
clore wallets
```

**示例输出：**

```
💰 钱包余额
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ 货币             ┃ 余额         ┃ 充值地址                                 ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ bitcoin          │ 0.00153176   │ tb1q6erw7v02t7hakgmlcl4wfnlykzqj05alndruwr │
│ CLORE-Blockchain │ 150.00000000 │ cLr1q8x...                                │
└──────────────────┴──────────────┴───────────────────────────────────────────┘
```

***

### `clore servers`

列出您在市场上托管的服务器。

```bash
clore servers
```

***

### `clore server-config <name>`

获取您托管的特定服务器的配置。

```bash
clore server-config "MyGPU"
```

**示例输出：**

```
服务器：MyGPU
ID：42
已连接：True
在线：True
可见性：public
最短租期：72
GPU：NVIDIA GeForce RTX 4090
按需价格（USD）：$0.35
现货价格（USD）：$0.18
CPU：AMD Ryzen 9 5900X 12 核处理器
内存：64.0 GB
GPU：1x NVIDIA GeForce RTX 4090
```

***

### `clore spot <server_id>`

查看服务器当前的现货市场报价。

```bash
clore spot 6
```

**示例输出：**

```
📊 现货市场 - 服务器 6
┏━━━━━━━━━━┳━━━━━━━━━━━┓
┃ 订单 ID ┃ 价格      ┃
┡━━━━━━━━━━╇━━━━━━━━━━━┩
│ 39       │ 4.2e-06   │
└──────────┴───────────┘
```

***

### `clore spot-price <order_id> <price>`

更新您现货市场报价的价格。

```bash
clore spot-price 39 0.000003
```

> **注意：** 您只能每 600 秒降低一次现货价格，并且每次降低受限于步长大小。

***

### `clore config`

管理 CLI 配置。

```bash
# 设置 API 密钥
clore config set api_key YOUR_API_KEY

# 获取一个值
clore config get api_key

# 显示所有配置
clore config show
```

配置存储在 `~/.clore/config.json`.

***

## 工作流程

### 搜索 → 租用 → SSH → 取消

典型的端到端工作流程：

```bash
# 1. 找到每小时低于 $5 的 RTX 4090
clore search --gpu "RTX 4090" --max-price 5.0 --sort price --limit 5

# 2. 在最便宜的服务器上部署（例如 ID 123）
clore deploy 123 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password MyPass123 \
  --port 22:tcp \
  --port 8888:http

# 3. 检查您的订单状态
clore orders

# 4. SSH 登录到实例（例如订单 ID 456）
clore ssh 456

# 5. 完成后，取消订单
clore cancel 456
```

### 在租用前监控余额

```bash
# 检查您是否有足够的资金
clore wallets

# 搜索并租用
clore search --gpu "A100" --sort price --limit 3
clore deploy 789 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password SecurePass \
  --port 22:tcp
```

### 现货市场工作流程

```bash
# 1. 检查某台服务器的现货报价
clore spot 6

# 2. 创建现货订单
clore deploy 6 \
  --image cloreai/pytorch \
  --type spot \
  --currency bitcoin \
  --spot-price 0.000005 \
  --ssh-password MyPass123 \
  --port 22:tcp

# 3. 调整您的现货价格
clore spot-price 39 0.000003
```

### 服务器托管管理

```bash
# 查看您的服务器
clore servers

# 检查某台服务器的配置
clore server-config "MyGPU"
```

***

## 下一步

* [**Python SDK**](/clore.ai/clore.ai-eng-zh/kai-fa-zhe/python-sdk.md) — 使用 Python 自动化工作流程
* [**REST API**](/clore.ai/clore.ai-eng-zh/zhen-dui-zhu-ji/api.md) — 原始 API 文档
* [**按需 vs 现货**](/clore.ai/clore.ai-eng-zh/zhen-dui-zu-yong-zhe/on-demand-vs-spot.md) — 了解定价模型


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/clore.ai/clore.ai-eng-zh/kai-fa-zhe/cli-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
