Skip to content

Commit 6208c17

Browse files
authored
Merge pull request #2 from pinecone-io/env-troubleshooting
Changes to correct env usage and fix index creation
2 parents 75a6a97 + f347e08 commit 6208c17

File tree

4 files changed

+93
-11
lines changed

4 files changed

+93
-11
lines changed

.agents/PINECONE-cli.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,37 @@ pc auth login
4848
- **Use Option 2 (API Key)** or **Option 3 (Service Account)** instead
4949
- These methods work in all environments and are better suited for automation
5050

51+
### Option 2a: Environment Variable (Recommended for Quickstarts)
52+
53+
Simplest method - CLI reads `PINECONE_API_KEY` from your environment:
54+
55+
1. Create `.env` file:
56+
57+
```bash
58+
PINECONE_API_KEY=your-api-key-here
59+
```
60+
61+
2. Load into shell:
62+
63+
```bash
64+
source .env
65+
```
66+
67+
3. Export for CLI use (required for quickstart):
68+
69+
```bash
70+
export PINECONE_API_KEY
71+
```
72+
73+
4. CLI commands now work automatically.
74+
75+
**Benefits:**
76+
- Same API key for CLI and SDK
77+
- No separate configuration step
78+
- Perfect for development and quickstarts
79+
80+
**Note:** Only persists for current shell session. For persistent auth, use Option 2 below.
81+
5182
### Option 2: API Key
5283

5384
Use for most automated scenarios, CI/CD, or when browser access is unavailable. Scoped to a specific project.
@@ -135,10 +166,16 @@ pc api-key delete --key-id <key-id>
135166
# 1. Install CLI (check first: pc version)
136167
brew tap pinecone-io/tap && brew install pinecone-io/tap/pinecone
137168

138-
# 2. Check authentication status (check first: pc auth status)
139-
# For interactive environments with browser access:
169+
# 2. Authenticate (choose one method):
170+
171+
# Option A: Environment variable (recommended for quickstarts)
172+
# Create .env file with PINECONE_API_KEY=your-key, then:
173+
source .env
174+
175+
# Option B: Interactive login (requires browser)
140176
pc auth login
141-
# OR for non-interactive/automated environments:
177+
178+
# Option C: Direct API key configuration (persists across sessions)
142179
pc auth configure --api-key your-api-key
143180

144181
# 3. Verify target (if already authenticated) and set it if needed
@@ -198,7 +235,7 @@ pc index create -n my-app-prod -m cosine -c aws -r us-east-1 \
198235
| ----------------------------------------- | -------------------------------------------------------------------------------- |
199236
| `pc: command not found` | Install CLI: `brew tap pinecone-io/tap && brew install pinecone-io/tap/pinecone` |
200237
| `Unknown command` or unrecognized command | See troubleshooting steps above (check version, update if needed) |
201-
| `Authentication failed` | Run `pc auth login` or set an API key or service account |
238+
| `Authentication failed` | Run `source .env` (if using .env file), `pc auth login`, or `pc auth configure --api-key` |
202239
| `Index already exists` | Use different name or delete existing: `pc index delete --name <name>` |
203240
| `Permission denied` | Check API key permissions or organization access |
204241

.agents/PINECONE-python.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,26 @@ class PineconeClient:
211211

212212
Complete setup prerequisites first, then:
213213

214+
**Before running commands, ensure environment is ready:**
215+
216+
```bash
217+
# Load API key into environment (CLI will use this)
218+
source .env
219+
220+
# Export for CLI use (required for quickstart)
221+
export PINECONE_API_KEY
222+
223+
# Activate virtual environment
224+
source venv/bin/activate
225+
```
226+
214227
1. **Create index with CLI:**
215228

216229
```bash
217230
pc index create -n agentic-quickstart-test -m cosine -c aws -r us-east-1 --model llama-text-embed-v2 --field_map text=content
231+
232+
# Wait for index to be ready
233+
sleep 5
218234
```
219235

220236
2. **Upsert sample data:**

.agents/PINECONE-quickstart.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,37 @@ implementation 'io.pinecone:pinecone-client:5.1.0'
178178

179179
**⚠️ Use `.env` files (see [PINECONE.md](./PINECONE.md#-environment-variables--security-best-practices) for details).**
180180

181-
Create `.env` file:
181+
**Recommended Workflow (CLI + SDK):**
182+
183+
1. **Create `.env` file** in your project root:
182184

183185
```bash
184186
PINECONE_API_KEY=your-api-key-here
185187
```
186188

187-
**CLI authentication:**
189+
2. **Load into your shell:**
190+
191+
```bash
192+
source .env
193+
```
194+
195+
3. **Export for CLI use** (required for quickstart):
196+
197+
```bash
198+
export PINECONE_API_KEY
199+
```
200+
201+
4. **Activate virtual environment** (if using Python):
202+
203+
```bash
204+
source venv/bin/activate
205+
```
206+
207+
Now both CLI commands (`pc index create ...`) and Python scripts (using `python-dotenv`) will use the same API key.
208+
209+
**Alternative: Persistent CLI Authentication**
210+
211+
If you prefer CLI authentication that persists across shell sessions:
188212

189213
```bash
190214
pc auth configure --api-key your-api-key-here
@@ -207,10 +231,11 @@ Add to `.env`: `OPENAI_API_KEY=...`, `ANTHROPIC_API_KEY=...`, or `GROQ_API_KEY=.
207231
### Steps
208232

209233
1. **Create an index** with integrated embeddings using CLI
210-
2. **Prepare sample data** from different domains (history, science, art, etc.)
211-
3. **Upsert data** into the index
212-
4. **Search** for semantically similar documents
213-
5. **Rerank results** for better accuracy
234+
2. **Wait for index** to be ready (sleep 5 seconds)
235+
3. **Prepare sample data** from different domains (history, science, art, etc.)
236+
4. **Upsert data** into the index
237+
5. **Search** for semantically similar documents
238+
6. **Rerank results** for better accuracy
214239

215240
### Sample Data (Use in All Languages)
216241

.agents/PINECONE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ Based on what the user is asking, consult these guides:
7171
7272
### ⚠️ Critical: CLI Authentication (When Using CLI)
7373

74-
> **When using CLI for index creation or management**: ALWAYS check if the CLI is already authenticated by running `pc auth status` before prompting for authentication setup. See [PINECONE-cli.md](./PINECONE-cli.md#authentication) for details on interpreting the output.
74+
> **When using CLI for index creation or management**:
75+
>
76+
> **For quickstarts:** Create a `.env` file with `PINECONE_API_KEY` and run `source .env`. The CLI automatically detects the environment variable - no separate authentication needed.
77+
>
78+
> **For persistent authentication:** Run `pc auth status` to check if already authenticated. See [PINECONE-cli.md](./PINECONE-cli.md#authentication) for `pc auth configure` and other options.
7579
7680
### ⚠️ MANDATORY: Always Use Latest Version
7781

0 commit comments

Comments
 (0)