null
Pinecone quick reference for agents
Official docs: https://docs.pinecone.io/ - For complete API reference, advanced features, and detailed guides.This guide covers critical gotchas, best practices, and common patterns specific to this project. For anything not covered here, consult the official Pinecone documentation.
⚠️ Critical: Installation & SDK
ALWAYS use the current SDK:🚫 CRITICAL: CLI for Admin, SDK for Data
ALWAYS use CLI for administrative tasks:- ❌ NEVER call
pc.create_index()
,pc.delete_index()
,pc.configure_index()
in code - ✅ ALWAYS use
pc index create
,pc index delete
,pc index configure
commands - Reason: Admin operations are one-time setup tasks, not application logic
- Data operations: upsert, query, search, fetch, delete records
- Runtime checks:
pc.has_index()
,index.describe_index_stats()
🔧 CLI vs SDK: When to Use Which
Use the Pinecone CLI for:- ✅ Creating indexes -
pc index create
- ✅ Deleting indexes -
pc index delete
- ✅ Configuring indexes -
pc index configure
(replicas, deletion protection) - ✅ Listing indexes -
pc index list
- ✅ Describing indexes -
pc index describe
- ✅ Creating API keys -
pc api-key create
- ✅ One-off inspection - Checking stats, configuration
- ✅ Development setup - All initial infrastructure setup
- ✅ Data operations in application code - upsert, query, search, delete RECORDS
- ✅ Runtime checks -
pc.has_index()
,index.describe_index_stats()
- ✅ Automated workflows - Any data operations that run repeatedly
- ✅ Production data access - Reading and writing vectors/records
- Creating, deleting, or configuring indexes in application code
- One-time administrative tasks
Installing the Pinecone CLI
macOS (Homebrew):CLI Authentication
Choose one method: Option 1: User login (recommended for development)Common CLI Commands
Quick Start Pattern
⚠️ CREATING INDEXES: Use the CLI (pc index create
), NOT the SDK in application code. See CLI vs SDK section.
🚨 Common Mistakes (Must Avoid)
1. Nested Metadata (will cause API errors)
2. Batch Size Limits (will cause API errors)
3. Missing Namespaces (causes data isolation issues)
4. Skipping Reranking (reduces search quality)
5. Hardcoded API Keys
6. Using SDK for Administrative Tasks (wrong tool)
- Admin operations are one-time setup tasks, not application logic
- Mixing setup and runtime code makes applications fragile
- CLI provides better error messages and interactive feedback
- Prevents accidental index deletion in production code
Key Constraints
Constraint | Limit | Notes |
---|---|---|
Metadata per record | 40KB | Flat JSON only, no nested objects |
Text batch size | 96 records | Also 2MB total per batch |
Vector batch size | 1000 records | Also 2MB total per batch |
Query response size | 4MB | Per query response |
Metadata types | strings, ints, floats, bools, string lists | No nested structures |
Consistency | Eventually consistent | Wait ~1-5s after upsert |
Error Handling (Production)
Error Types
- 4xx (client errors): Fix your request - DON’T retry (except 429)
- 429 (rate limit): Retry with exponential backoff
- 5xx (server errors): Retry with exponential backoff
Simple Retry Pattern
Common Operations Cheat Sheet
Index Management
⚠️ Important: For administrative tasks (create, configure, delete indexes), prefer the Pinecone CLI over the SDK. Use the SDK only when you need to check index existence or get stats programmatically in your application code. Use CLI for these operations:Data Operations
Search with Filters
Recommended Patterns
Namespace Strategy
Batch Processing
Environment Config
Embedding Models (2025)
Integrated embeddings (recommended - Pinecone handles embedding):llama-text-embed-v2
: High-performance, recommended for most casesmultilingual-e5-large
: Multilingual content (1024 dims)pinecone-sparse-english-v0
: Keyword/hybrid search
Official Documentation Resources
For advanced features not covered in this quick reference:- API reference: https://docs.pinecone.io/reference/api/introduction
- Bulk imports (S3/GCS): https://docs.pinecone.io/guides/index-data/import-data
- Hybrid search: https://docs.pinecone.io/guides/search/hybrid-search
- Back ups (backup/restore): https://docs.pinecone.io/guides/manage-data/backups-overview
- Error handling: https://docs.pinecone.io/guides/production/error-handling
- Database limits: https://docs.pinecone.io/reference/api/database-limits
- Production monitoring: https://docs.pinecone.io/guides/production/monitoring
- Python SDK docs: https://sdk.pinecone.io/python/index.html
Quick Troubleshooting
Issue | Solution |
---|---|
ModuleNotFoundError: pinecone.grpc | Wrong SDK - reinstall with pip install pinecone |
Metadata too large error | Check 40KB limit, flatten nested objects |
Batch too large error | Reduce to 96 records (text) or 1000 (vectors) |
Search returns no results | Check namespace, wait for indexing (~5s), verify data exists |
Rate limit (429) errors | Implement exponential backoff, reduce request rate |
Nested metadata error | Flatten all metadata - no nested objects allowed |
Remember: Always use namespaces, always rerank, always handle errors with retry logic.