pinecone-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePinecone CLI (pc
)
pcPinecone CLI (pc
)
pcManage 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
| CLI | MCP | |
|---|---|---|
| Index types | All (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 | ✅ | ❌ |
| CLI | MCP | |
|---|---|---|
| 索引类型 | 全部(标准型、集成型、稀疏型) | 仅集成型 |
| 向量操作(upsert、query、fetch、update、delete) | ✅ | ❌ |
| 集成型索引上的文本搜索 | ✅ | ✅ |
| 备份、命名空间、组织/项目管理 | ✅ | ❌ |
| CI/CD / 脚本编写 | ✅ | ❌ |
Setup
设置
Install (macOS)
安装(macOS)
bash
brew tap pinecone-io/tap
brew install pinecone-io/tap/pineconeOther 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
undefinedbash
undefinedInteractive (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
PINECONE_API_KEYCLI身份验证不会设置PINECONE_API_KEY
PINECONE_API_KEYpc loginPINECONE_API_KEYPINECONE_API_KEYUse 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 : run and copy the field manually.
jqpc api-key create --name agent-sdk-key --json"value"pc loginPINECONE_API_KEYPINECONE_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
常用命令
| Task | Command |
|---|---|
| List indexes | |
| Create serverless index | |
| Index stats | |
| Upload vectors from file | |
| Query by vector | |
| Query by vector ID | |
| Fetch vectors by ID | |
| List vector IDs | |
| Delete vectors by filter | |
| List namespaces | |
| Create backup | |
| JSON output (for scripting) | Add |
| 任务 | 命令 |
|---|---|
| 列出索引 | |
| 创建无服务器索引 | |
| 索引统计信息 | |
| 从文件上传向量 | |
| 通过向量查询 | |
| 通过向量ID查询 | |
| 通过ID获取向量 | |
| 列出向量ID | |
| 通过过滤器删除向量 | |
| 列出命名空间 | |
| 创建备份 | |
| JSON输出(用于脚本编写) | 为任意命令添加 |
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-metadataPipe embeddings directly into queries
将嵌入直接通过管道传入查询
bash
jq -c '.embedding' doc.json | pc index vector query -n my-index --vector - -k 10bash
jq -c '.embedding' doc.json | pc index vector query -n my-index --vector - -k 10Bulk metadata update with preview
批量元数据更新并预览
bash
undefinedbash
undefinedPreview first
先预览
pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--dry-run
--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
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--dry-run
Apply
应用更新
pc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
undefinedpc index vector update -n my-index
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
--filter '{"env":{"$eq":"staging"}}'
--metadata '{"env":"production"}'
undefinedBackup and restore
备份与恢复
bash
undefinedbash
undefinedSnapshot 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
undefinedpc backup restore -i <backup-uuid> -n my-index-restored
undefinedAutomate 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 1000bash
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 1000Script against JSON output
针对JSON输出编写脚本
bash
undefinedbash
undefinedGet 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
- 完整命令参考 —— 所有命令及参数和示例
- 故障排除与最佳实践