pinecone-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pinecone CLI (
pc
)

Pinecone CLI (
pc
)

Manage Pinecone from the terminal. The CLI is especially valuable for vector operations across all index types — something the MCP currently can't do.
从终端管理Pinecone资源。该CLI对于跨所有索引类型的向量操作尤其有价值——这是MCP目前无法做到的。

CLI vs MCP

CLI vs MCP

CLIMCP
Index typesAll (standard, integrated, sparse)Integrated only
Vector ops (upsert, query, fetch, update, delete)
Text search on integrated indexes
Backups, namespaces, org/project mgmt
CI/CD / scripting

CLIMCP
索引类型全部(标准型、集成型、稀疏型)仅集成型
向量操作(upsert、query、fetch、update、delete)
集成型索引上的文本搜索
备份、命名空间、组织/项目管理
CI/CD / 脚本编写

Setup

设置

Install (macOS)

安装(macOS)

bash
brew tap pinecone-io/tap
brew install pinecone-io/tap/pinecone
Other platforms (Linux, Windows) — download from GitHub Releases.
bash
brew tap pinecone-io/tap
brew install pinecone-io/tap/pinecone
其他平台(Linux、Windows)——从GitHub Releases下载。

Authenticate

身份验证

bash
undefined
bash
undefined

Interactive (recommended for local dev)

交互式(本地开发推荐)

pc login pc target -o "my-org" -p "my-project"
pc login pc target -o "my-org" -p "my-project"

Service account (recommended for CI/CD)

服务账号(CI/CD推荐)

pc auth configure --client-id "$PINECONE_CLIENT_ID" --client-secret "$PINECONE_CLIENT_SECRET"
pc auth configure --client-id "$PINECONE_CLIENT_ID" --client-secret "$PINECONE_CLIENT_SECRET"

API key (quick testing)

API密钥(快速测试)

pc config set-api-key $PINECONE_API_KEY

Check status: `pc auth status` · `pc target --show`

> **Note for agent sessions**: If you need to run `pc login` inside an agent loop, the browser auth link may not surface correctly. It's best to authenticate **before** starting an agent session. Run `pc login` in your terminal directly, then invoke the agent once you're authenticated.
pc config set-api-key $PINECONE_API_KEY

检查状态:`pc auth status` · `pc target --show`

> **代理会话注意事项**:如果需要在代理循环内运行`pc login`,浏览器身份验证链接可能无法正确显示。最好在启动代理会话**之前**完成身份验证。直接在终端中运行`pc login`,完成验证后再调用代理。

Authenticating the CLI does not set
PINECONE_API_KEY

CLI身份验证不会设置
PINECONE_API_KEY

pc login
authenticates the CLI tool itself — it does not set
PINECONE_API_KEY
in your environment. Python scripts, Node.js SDKs, and other tools that use the Pinecone SDK need
PINECONE_API_KEY
set separately.
Use the CLI to create a key and export it in one step:
bash
KEY=$(pc api-key create --name agent-sdk-key --json | jq -r '.value')
export PINECONE_API_KEY="$KEY"
Without
jq
: run
pc api-key create --name agent-sdk-key --json
and copy the
"value"
field manually.

pc login
用于验证CLI工具本身——它不会在您的环境中设置
PINECONE_API_KEY
。使用Pinecone SDK的Python脚本、Node.js SDK及其他工具需要单独设置
PINECONE_API_KEY
使用CLI一键创建密钥并导出:
bash
KEY=$(pc api-key create --name agent-sdk-key --json | jq -r '.value')
export PINECONE_API_KEY="$KEY"
不使用jq:运行
pc api-key create --name agent-sdk-key --json
并手动复制
"value"
字段。

Common Commands

常用命令

TaskCommand
List indexes
pc index list
Create serverless index
pc index create -n my-index -d 1536 -m cosine -c aws -r us-east-1
Index stats
pc index stats -n my-index
Upload vectors from file
pc index vector upsert -n my-index --file ./vectors.json
Query by vector
pc index vector query -n my-index --vector '[0.1, ...]' -k 10 --include-metadata
Query by vector ID
pc index vector query -n my-index --id "doc-123" -k 10
Fetch vectors by ID
pc index vector fetch -n my-index --ids '["vec1","vec2"]'
List vector IDs
pc index vector list -n my-index
Delete vectors by filter
pc index vector delete -n my-index --filter '{"genre":"classical"}'
List namespaces
pc index namespace list -n my-index
Create backup
pc backup create -i my-index -n "my-backup"
JSON output (for scripting)Add
-j
to any command

任务命令
列出索引
pc index list
创建无服务器索引
pc index create -n my-index -d 1536 -m cosine -c aws -r us-east-1
索引统计信息
pc index stats -n my-index
从文件上传向量
pc index vector upsert -n my-index --file ./vectors.json
通过向量查询
pc index vector query -n my-index --vector '[0.1, ...]' -k 10 --include-metadata
通过向量ID查询
pc index vector query -n my-index --id "doc-123" -k 10
通过ID获取向量
pc index vector fetch -n my-index --ids '["vec1","vec2"]'
列出向量ID
pc index vector list -n my-index
通过过滤器删除向量
pc index vector delete -n my-index --filter '{"genre":"classical"}'
列出命名空间
pc index namespace list -n my-index
创建备份
pc backup create -i my-index -n "my-backup"
JSON输出(用于脚本编写)为任意命令添加
-j
参数

Interesting Things You Can Do

可实现的实用功能

Query with custom vectors (not just text)

使用自定义向量查询(不仅仅是文本)

Unlike the MCP, the CLI lets you query any index with raw vector values — useful when you generate embeddings externally (OpenAI, HuggingFace, etc.):
bash
pc index vector query -n my-index \
  --vector '[0.1, 0.2, ..., 0.9]' \
  --filter '{"source":{"$eq":"docs"}}' \
  -k 20 --include-metadata
与MCP不同,CLI允许您使用原始向量值查询任何索引——当您在外部生成嵌入(OpenAI、HuggingFace等)时非常有用:
bash
pc index vector query -n my-index \
  --vector '[0.1, 0.2, ..., 0.9]' \
  --filter '{"source":{"$eq":"docs"}}' \
  -k 20 --include-metadata

Pipe embeddings directly into queries

将嵌入直接通过管道传入查询

bash
jq -c '.embedding' doc.json | pc index vector query -n my-index --vector - -k 10
bash
jq -c '.embedding' doc.json | pc index vector query -n my-index --vector - -k 10

Bulk metadata update with preview

批量元数据更新并预览

bash
undefined
bash
undefined

Preview first

先预览

pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--dry-run
pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--dry-run

Apply

应用更新

pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
undefined
pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
undefined

Backup and restore

备份与恢复

bash
undefined
bash
undefined

Snapshot before a migration

迁移前创建快照

pc backup create -i my-index -n "pre-migration"
pc backup create -i my-index -n "pre-migration"

Restore to a new index if something goes wrong

若出现问题,恢复到新索引

pc backup restore -i <backup-uuid> -n my-index-restored
undefined
pc backup restore -i <backup-uuid> -n my-index-restored
undefined

Automate in CI/CD

在CI/CD中自动化

bash
export PINECONE_CLIENT_ID="..."
export PINECONE_CLIENT_SECRET="..."
pc auth configure --client-id "$PINECONE_CLIENT_ID" --client-secret "$PINECONE_CLIENT_SECRET"
pc index vector upsert -n my-index --file ./vectors.jsonl --batch-size 1000
bash
export PINECONE_CLIENT_ID="..."
export PINECONE_CLIENT_SECRET="..."
pc auth configure --client-id "$PINECONE_CLIENT_ID" --client-secret "$PINECONE_CLIENT_SECRET"
pc index vector upsert -n my-index --file ./vectors.jsonl --batch-size 1000

Script against JSON output

针对JSON输出编写脚本

bash
undefined
bash
undefined

Get all index names as a list

获取所有索引名称列表

pc index list -j | jq -r '.[] | .name'
pc index list -j | jq -r '.[] | .name'

Check if an index exists before creating

创建前检查索引是否存在

if ! pc index describe -n my-index -j 2>/dev/null | jq -e '.name' > /dev/null; then pc index create -n my-index -d 1536 -m cosine -c aws -r us-east-1 fi

---
if ! pc index describe -n my-index -j 2>/dev/null | jq -e '.name' > /dev/null; then pc index create -n my-index -d 1536 -m cosine -c aws -r us-east-1 fi

---

Reference Files

参考文件

  • Full command reference — all commands with flags and examples
  • Troubleshooting & best practices
  • 完整命令参考 —— 所有命令及参数和示例
  • 故障排除与最佳实践

Documentation

文档