SuperAPI AI Directory

cbi-shared

Deployment & operations

View repository

Updated 10-16 06:52

About this skill

CreatiBI CLI Basic Configuration and Authentication

Initialization and authentication module for the CreatiBI command-line tool.

Installation

# npm 全局安装
npm install -g @creatibi/cbi-cli@latest

Supported platforms: macOS (amd64/arm64), Linux (amd64/arm64), Windows (amd64/arm64)


Quick Start

# 1. 初始化配置(首次使用)
cbi config init

# 2. OAuth 登录
cbi auth login

# 3. 确认登录成功
cbi auth whoami

Common Command Quick Reference

Scenario Command
Initialize configuration cbi config init
Force re-initialization cbi config init --new
Device code mode initialization cbi config init --device
View configuration cbi config show
Login authorization cbi auth login
Device code login cbi auth login --device
View identity cbi auth whoami
Log out cbi auth logout

Configuration module (config)

Initialize configuration

First-time use requires initializing the application credential configuration:

# 初始化配置(交互式选择模式)
cbi config init

# 强制重新初始化(覆盖已有配置)
cbi config init --new

# 直接使用设备码模式(适用于 VPS/服务器)
cbi config init --device

Two initialization modes are supported:

Mode Applicable scenario Description
Callback mode Desktop environment Create credentials in the local browser, automatically sent back
Device code mode VPS/server Create credentials in a remote browser, obtained by polling

Callback mode flow:

  1. CLI starts a local callback server (port 8080)
  2. Automatically opens the browser to visit the open platform
  3. The user creates/selects an application on the open platform
  4. Credentials are automatically sent back to the CLI
  5. Configuration is written to ~/.cbi/config.json

Device code mode flow:

  1. CLI requests a device code from the platform
  2. CLI displays the verification URL and verification code (e.g., 550e-8400)
  3. The user visits the verification URL in any browser and confirms authorization
  4. CLI polls and waits for authorization (valid for 15 minutes)
  5. After successful authorization, obtains app_id/app_secret
  6. Configuration is written to ~/.cbi/config.json

Prerequisites: Create an application on the CreatiBI open platform to obtain client_id and client_secret

Display current configuration

cbi config show              # 显示配置(敏感字段脱敏)
cbi config show -v           # 详细模式(显示登录凭证)
cbi config show --format json   # JSON 格式输出

Authentication module (auth)

OAuth login

cbi auth login

Prerequisites: Already executed cbi config init to configure application credentials

Two login modes are supported:

Mode Applicable scenario Description
Authorization code mode Desktop environment Local browser authorization, automatic callback
Device code mode VPS/server Remote browser authorization, manually enter the verification code

Authorization code mode flow:

  1. CLI starts a local callback server (port 8080)
  2. Automatically opens the browser to visit the authorization page
  3. The user completes authorization in the browser
  4. The server calls back to the CLI and returns the authorization code
  5. CLI uses the authorization code to exchange for an access_token
  6. Token is stored in ~/.cbi/config.json

Device code mode flow:

  1. CLI requests a device code from the server
  2. CLI displays the verification URL and verification code (e.g., 550e-8400)
  3. The user visits the verification URL in any browser and enters the verification code
  4. The CLI polls and waits for user authorization
  5. After successful authorization, the access_token is obtained
# 直接使用设备码模式
cbi auth login --device

# 或通过环境变量设置
export CBI_LOGIN_MODE=device
cbi auth login

View the current identity

cbi auth whoami      # 查看当前登录身份
cbi auth whoami -v   # 详细模式(显示 token 信息)

Log out

cbi auth logout

Error handling

Insufficient permissions / not logged in

When encountering permission denied or auth required errors:

# 1. 检查配置是否存在
cbi config show

# 2. 如果配置不存在,先初始化
cbi config init

# 3. 登录授权
cbi auth login

# 4. 确认登录成功
cbi auth whoami

Token expired

When encountering expired access token errors:

cbi auth login   # 重新登录

Configuration file issues

cbi config init --new   # 强制重新初始化配置
cbi auth login          # 重新登录

Configuration file location

The configuration is stored in ~/.cbi/config.json:

{
  "base_url": "https://open.creatibi.cn",
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "api_key": "YOUR_ACCESS_TOKEN",
  "refresh_token": "YOUR_REFRESH_TOKEN",
  "token_expires_at": "2026-04-24T00:28:54Z"
}

General parameters

Parameter Description
--config <path> Configuration file path (default ~/.cbi/config.json)
-f, --format Output format: json / table
-v, --verbose Show detailed information