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

# 通过 CLI 快速使用 HubTo

> 使用 hubtoai 登录 HubTo，并自动配置本机 AI CLI。

## 这是什么

`hubtoai` 是 HubTo CLI 的 npm 包和命令。

它用于登录 HubTo，并把凭证自动写入本机 AI CLI，例如 Claude Code、Codex、OpenCode、Gemini CLI 和 Pi。

## 最快使用

### 方式一：不安装，直接运行

```bash theme={null}
npx hubtoai@latest login
```

### 方式二：全局安装后运行

```bash theme={null}
npm install -g hubtoai
hubtoai login
```

运行后，按提示选择要配置的 AI CLI，并在浏览器中完成 HubTo 登录。

登录完成后，重启已经打开的 AI CLI，让新配置生效。

## 会配置什么

`hubtoai` 会自动处理这些信息：

* HubTo 登录状态
* API Key
* Base URL
* 目标 CLI 的本地配置

当前支持的目标 CLI：

* `claude-code`：Claude Code
* `codex`：Codex
* `opencode`：OpenCode
* `gemini`：Gemini CLI
* `pi`：Pi

## 指定目标 CLI

只配置 Gemini CLI：

```bash theme={null}
hubtoai login --target gemini
```

同时配置 Claude Code 和 Codex：

```bash theme={null}
hubtoai login --target claude-code --target codex
```

配置所有已检测到的目标：

```bash theme={null}
hubtoai login --all
```

## 常用命令

查看当前状态：

```bash theme={null}
hubtoai status
```

检查登录、接口和本地配置：

```bash theme={null}
hubtoai doctor
```

刷新登录状态并同步到目标 CLI：

```bash theme={null}
hubtoai refresh --use-saved-targets
```

退出登录并清理配置：

```bash theme={null}
hubtoai logout --use-saved-targets
```

## 远程环境登录

如果服务器或容器不能自动打开浏览器，先打印登录链接：

```bash theme={null}
hubtoai login --print-auth-url
```

在浏览器中完成登录后，把最终回调地址复制回终端：

```bash theme={null}
hubtoai login complete "<callback-url>"
```

## 常见问题

### 登录后没有生效

请先重启对应 AI CLI。

如果仍然无效，运行：

```bash theme={null}
hubtoai status
hubtoai doctor
```

### 找不到目标 CLI

请确认目标名称使用的是：

```txt theme={null}
claude-code
codex
opencode
gemini
pi
```

### 需要更新 hubtoai

重新安装最新版：

```bash theme={null}
npm install -g hubtoai@latest
```

## 下一步

* 获取 API Key：参见 [快速上手](/cn/quickstart)
* 查看接口文档：参见 [接口参考](/cn/api-reference/introduction)
