upstash-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
The Upstash CLI (
upstash
) manages Upstash services via the Upstash Developer API. All commands are non-interactive and emit JSON on stdout. Errors go to stderr as
{ "error": "..." }
with exit code
1
.
Upstash CLI(
upstash
)通过Upstash Developer API管理Upstash服务。所有命令均为非交互式,会在标准输出(stdout)中输出JSON格式内容。错误信息会以
{ "error": "..." }
的格式输出到标准错误(stderr),并返回退出码
1

Install

安装

bash
npm i -g @upstash/cli
bash
npm i -g @upstash/cli

Authentication

认证

Recommended: run
upstash login
once per machine. Prompts for email and a Developer API key (create one at https://console.upstash.com/account/api), verifies them, and saves to
~/.config/upstash/config.json
.
bash
upstash login
Alternatives — env vars (also auto-loaded from a
.env
in cwd), or
--email
/
--api-key
inline, or
--env-path <path>
to point at a specific
.env
:
bash
export UPSTASH_EMAIL=you@example.com
export UPSTASH_API_KEY=your_api_key
Precedence: flags > env vars >
.env
> saved config. Prefer a read-only API key for agents when possible — mutations fail at the API, the same way they would in the console.
推荐方式:每台机器运行一次
upstash login
。会提示输入邮箱和Developer API密钥(可在https://console.upstash.com/account/api创建),验证通过后将保存至`~/.config/upstash/config.json`。
bash
upstash login
其他方式——环境变量(也会自动加载当前目录下的
.env
文件),或在命令行中通过
--email
/
--api-key
传入,或使用
--env-path <path>
指定特定的
.env
文件路径:
bash
export UPSTASH_EMAIL=you@example.com
export UPSTASH_API_KEY=your_api_key
优先级:命令行参数 > 环境变量 >
.env
文件 > 已保存的配置。尽可能为代理使用只读API密钥——此时API层面会拒绝修改操作,与控制台中的表现一致。

Resource ID flags

资源ID参数

FlagProducts
--db-id <id>
Redis
--index-id <id>
Vector, Search
--qstash-id <id>
QStash
--team-id <id>
Team
参数产品
--db-id <id>
Redis
--index-id <id>
Vector, Search
--qstash-id <id>
QStash
--team-id <id>
Team

Redis

Redis

bash
upstash redis list
upstash redis get --db-id <id> [--hide-credentials]
upstash redis create --name <name> --region <region> [--read-regions <r1> <r2>]
upstash redis delete --db-id <id> [--dry-run]
upstash redis rename --db-id <id> --name <new-name>
upstash redis reset-password --db-id <id>
upstash redis stats --db-id <id>

upstash redis enable-tls --db-id <id>
upstash redis {enable,disable}-eviction --db-id <id>
upstash redis {enable,disable}-autoupgrade --db-id <id>
upstash redis change-plan --db-id <id> --plan <free|payg|pro|paid>
upstash redis update-budget --db-id <id> --budget <cents>
upstash redis update-regions --db-id <id> --read-regions <r1> <r2>
upstash redis move-to-team --db-id <id> --team-id <id>
Regions — AWS:
us-east-1
,
us-east-2
,
us-west-1
,
us-west-2
,
ca-central-1
,
eu-central-1
,
eu-west-1
,
eu-west-2
,
sa-east-1
,
ap-south-1
,
ap-northeast-1
,
ap-southeast-1
,
ap-southeast-2
,
af-south-1
. GCP:
us-central1
,
us-east4
,
europe-west1
,
asia-northeast1
.
bash
upstash redis list
upstash redis get --db-id <id> [--hide-credentials]
upstash redis create --name <name> --region <region> [--read-regions <r1> <r2>]
upstash redis delete --db-id <id> [--dry-run]
upstash redis rename --db-id <id> --name <new-name>
upstash redis reset-password --db-id <id>
upstash redis stats --db-id <id>

upstash redis enable-tls --db-id <id>
upstash redis {enable,disable}-eviction --db-id <id>
upstash redis {enable,disable}-autoupgrade --db-id <id>
upstash redis change-plan --db-id <id> --plan <free|payg|pro|paid>
upstash redis update-budget --db-id <id> --budget <cents>
upstash redis update-regions --db-id <id> --read-regions <r1> <r2>
upstash redis move-to-team --db-id <id> --team-id <id>
区域——AWS:
us-east-1
,
us-east-2
,
us-west-1
,
us-west-2
,
ca-central-1
,
eu-central-1
,
eu-west-1
,
eu-west-2
,
sa-east-1
,
ap-south-1
,
ap-northeast-1
,
ap-southeast-1
,
ap-southeast-2
,
af-south-1
。GCP:
us-central1
,
us-east4
,
europe-west1
,
asia-northeast1
.

Redis backups

Redis备份

bash
upstash redis backup list --db-id <id>
upstash redis backup create --db-id <id> --name <name>
upstash redis backup delete --db-id <id> --backup-id <id> [--dry-run]
upstash redis backup restore --db-id <id> --backup-id <id>
upstash redis backup {enable,disable}-daily --db-id <id>
bash
upstash redis backup list --db-id <id>
upstash redis backup create --db-id <id> --name <name>
upstash redis backup delete --db-id <id> --backup-id <id> [--dry-run]
upstash redis backup restore --db-id <id> --backup-id <id>
upstash redis backup {enable,disable}-daily --db-id <id>

Redis exec (REST, not the Developer API key)

Redis执行(使用REST,而非Developer API密钥)

bash
upstash redis exec --db-url <url> --db-token <token> SET key value
upstash redis exec --db-url <url> --db-token <token> --json '["SET","key","value"]'
--db-url
/
--db-token
fall back to
UPSTASH_REDIS_REST_URL
/
UPSTASH_REDIS_REST_TOKEN
. Get both from
endpoint
and
rest_token
in
upstash redis get --db-id <id>
.
bash
upstash redis exec --db-url <url> --db-token <token> SET key value
upstash redis exec --db-url <url> --db-token <token> --json '["SET","key","value"]'
--db-url
/
--db-token
会 fallback 到环境变量
UPSTASH_REDIS_REST_URL
/
UPSTASH_REDIS_REST_TOKEN
。可通过
upstash redis get --db-id <id>
endpoint
rest_token
字段获取这两个值。

Team

团队

bash
upstash team list
upstash team create --name <name> [--copy-cc]
upstash team delete --team-id <id> [--dry-run]
upstash team members --team-id <id>
upstash team add-member --team-id <id> --member-email <email> --role <admin|dev|finance>
upstash team remove-member --team-id <id> --member-email <email> [--dry-run]
bash
upstash team list
upstash team create --name <name> [--copy-cc]
upstash team delete --team-id <id> [--dry-run]
upstash team members --team-id <id>
upstash team add-member --team-id <id> --member-email <email> --role <admin|dev|finance>
upstash team remove-member --team-id <id> --member-email <email> [--dry-run]

Vector

Vector

bash
upstash vector list
upstash vector get --index-id <id>
upstash vector create --name <name> --region <region> --similarity-function <fn> --dimension-count <n> [--type payg] [--index-type <type>] [--embedding-model <m>] [--sparse-embedding-model <m>]
upstash vector delete --index-id <id> [--dry-run]
upstash vector rename --index-id <id> --name <new-name>
upstash vector reset-password --index-id <id>
upstash vector set-plan --index-id <id> --plan <free|payg|fixed>
upstash vector transfer --index-id <id> --target-account <id>
upstash vector stats                             # aggregate across all indexes
upstash vector index-stats --index-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
Regions:
eu-west-1
,
us-east-1
,
us-central1
. Similarity:
COSINE
,
EUCLIDEAN
,
DOT_PRODUCT
. Index types:
DENSE
,
SPARSE
,
HYBRID
. Dense models:
BGE_SMALL_EN_V1_5
,
BGE_BASE_EN_V1_5
,
BGE_LARGE_EN_V1_5
,
BGE_M3
. Sparse models:
BM25
,
BGE_M3
. For
HYBRID
with managed embeddings, set
--dimension-count 0
.
bash
upstash vector list
upstash vector get --index-id <id>
upstash vector create --name <name> --region <region> --similarity-function <fn> --dimension-count <n> [--type payg] [--index-type <type>] [--embedding-model <m>] [--sparse-embedding-model <m>]
upstash vector delete --index-id <id> [--dry-run]
upstash vector rename --index-id <id> --name <new-name>
upstash vector reset-password --index-id <id>
upstash vector set-plan --index-id <id> --plan <free|payg|fixed>
upstash vector transfer --index-id <id> --target-account <id>
upstash vector stats                             # 所有索引的聚合统计
upstash vector index-stats --index-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
区域:
eu-west-1
,
us-east-1
,
us-central1
。相似度函数:
COSINE
,
EUCLIDEAN
,
DOT_PRODUCT
。索引类型:
DENSE
,
SPARSE
,
HYBRID
。稠密模型:
BGE_SMALL_EN_V1_5
,
BGE_BASE_EN_V1_5
,
BGE_LARGE_EN_V1_5
,
BGE_M3
。稀疏模型:
BM25
,
BGE_M3
。对于使用托管嵌入的
HYBRID
索引,设置
--dimension-count 0

Search

Search

bash
upstash search list
upstash search get --index-id <id>
upstash search create --name <name> --region <region> --type <free|payg|fixed>
upstash search delete --index-id <id> [--dry-run]
upstash search rename --index-id <id> --name <new-name>
upstash search reset-password --index-id <id>
upstash search transfer --index-id <id> --target-account <id>
upstash search stats
upstash search index-stats --index-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
Regions:
eu-west-1
,
us-central1
.
bash
upstash search list
upstash search get --index-id <id>
upstash search create --name <name> --region <region> --type <free|payg|fixed>
upstash search delete --index-id <id> [--dry-run]
upstash search rename --index-id <id> --name <new-name>
upstash search reset-password --index-id <id>
upstash search transfer --index-id <id> --target-account <id>
upstash search stats
upstash search index-stats --index-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
区域:
eu-west-1
,
us-central1

QStash

QStash

bash
upstash qstash list                              # run first; maps region → id
upstash qstash get --qstash-id <id>
upstash qstash rotate-token --qstash-id <id>
upstash qstash set-plan --qstash-id <id> --plan <paid|qstash_fixed_1m|qstash_fixed_10m|qstash_fixed_100m>
upstash qstash stats --qstash-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
upstash qstash ipv4                              # CIDR blocks for allowlisting
upstash qstash move-to-team --qstash-id <id> --target-team-id <id>
upstash qstash update-budget --qstash-id <id> --budget <dollars>    # 0 = no limit
upstash qstash {enable,disable}-prodpack --qstash-id <id>
bash
upstash qstash list                              # 先运行此命令;映射区域→ID
upstash qstash get --qstash-id <id>
upstash qstash rotate-token --qstash-id <id>
upstash qstash set-plan --qstash-id <id> --plan <paid|qstash_fixed_1m|qstash_fixed_10m|qstash_fixed_100m>
upstash qstash stats --qstash-id <id> [--period <1h|3h|12h|1d|3d|7d|30d>]
upstash qstash ipv4                              # 用于白名单的CIDR块
upstash qstash move-to-team --qstash-id <id> --target-team-id <id>
upstash qstash update-budget --qstash-id <id> --budget <dollars>    # 0表示无限制
upstash qstash {enable,disable}-prodpack --qstash-id <id>

Conventions

约定

  • Pipe any output to
    jq
    for field extraction, e.g.
    upstash redis list | jq '.[].database_id'
    .
  • Use
    --dry-run
    first on any
    delete
    or
    remove-member
    .
  • Use
    --hide-credentials
    on
    redis get
    when the password isn't needed.
  • 可将任何输出通过管道传递给
    jq
    进行字段提取,例如
    upstash redis list | jq '.[].database_id'
  • 在执行任何
    delete
    remove-member
    命令前,先使用
    --dry-run
    测试。
  • 当不需要密码时,在
    redis get
    命令中使用
    --hide-credentials
    参数。