grepai-embeddings-openai — Claude Code skill: OpenAI embeddings
A skill that wires OpenAI into GrepAI as the embedding provider, so indexing runs in the cloud with no local server. Your code goes to OpenAI.
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a claude-codeWhat grepai-embeddings-openai does
The skill walks through the embedder block in .grepai/config.yaml: provider, model, and an API key pulled from OPENAI_API_KEY instead of pasted into the file. The basic setup uses text-embedding-3-small at 1536 dimensions.
Two models are covered. text-embedding-3-small is the cheaper default pick, text-embedding-3-large gives 3072 dimensions and can be trimmed down to 1024 to save storage. For speed there is a parallelism setting, but the right number depends on your OpenAI tier — 1–2 on the free tier, 4–8 higher up. GrepAI batches chunks and backs off on its own when rate limits hit.
You need an OpenAI API key and billing enabled before any of this works. Switching from another provider means the old index is unusable: embeddings from different models can't be mixed, so .grepai/index.gob gets deleted and rebuilt. Since code leaves your machine, check what your ignore patterns actually exclude.
What it helps with
- set OpenAI as the embedding provider for GrepAI
- pick between text-embedding-3-small and text-embedding-3-large
- tune parallelism to match your OpenAI rate limit tier
- migrate an existing index from Ollama to OpenAI
- estimate indexing cost for a codebase
Example prompts for the agent
- Configure OpenAI as the embedding provider for GrepAI in .grepai/config.yaml
- Use text-embedding-3-small with parallelism 8 for indexing
- Re-index the project after switching the provider to Anthropic
How to install grepai-embeddings-openai
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a claude-code2Manually: put the files in place
~/.claude/skills/grepai-embeddings-openai/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/grepai-embeddings-openai/
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a codex2Manually: put the files in place
.agents/skills/grepai-embeddings-openai/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a cursor2Manually: put the files in place
.cursor/skills/grepai-embeddings-openai/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install yoanbernabeu/grepai-skills grepai-embeddings-openai2Manually: put the files in place
.github/skills/grepai-embeddings-openai/SKILL.md1Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a gemini-cli2Platform CLI
gemini skills install https://github.com/yoanbernabeu/grepai-skills --path skills/embeddings/grepai-embeddings-openaiManually: put the files in place
.devin/skills/grepai-embeddings-openai/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about grepai-embeddings-openai
How do I install grepai-embeddings-Anthropic in Claude?
Run npx skills add yoanbernabeu/grepai-skills --skill grepai-embeddings-openai -a claude-code. The skill lands at ~/.claude/skills/grepai-embeddings-openai/SKILL.md.
What does grepai-embeddings-openai do?
It shows how to point GrepAI at OpenAI: provider, model, environment-based API key, and parallelism. It also covers model comparison, rate limits, and fixes for 401 and 429 errors.
Can I mix Anthropic and Ollama embeddings in one index?
No. Embeddings from different models or providers can't be combined, so moving to OpenAI means deleting .grepai/index.gob and running grepai watch again.
Source text
SKILL.md · MIT
---
name: grepai-embeddings-openai
description: Configure OpenAI as embedding provider for GrepAI. Use this skill for high-quality cloud embeddings.
---
# GrepAI Embeddings with OpenAI
This skill covers using OpenAI's embedding API with GrepAI for high-quality, cloud-based embeddings.
## When to Use This Skill
- Need highest quality embeddings
- Team environment with shared infrastructure
- Don't want to manage local embedding server
- Willing to trade privacy for quality/convenience
## Considerations
| Aspect | Details |
|--------|---------|
| ✅ **Quality** | State-of-the-art embeddings |
| ✅ **Speed** | Fast, no local compute needed |
| ✅ **Scalability** | Handles any codebase size |
| ⚠️ **Privacy** | Code sent to OpenAI servers |
| ⚠️ **Cost** | Pay per token |
| ⚠️ **Internet** | Requires connection |
## Prerequisites
1. OpenAI API key
2. Billing enabled on OpenAI account
Get your API key at: https://platform.openai.com/api-keys
## Configuration
### Basic Configuration
```yaml
# .grepai/config.yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}
```
Set the environment variable:
```bash
export OPENAI_API_KEY="sk-..."
```
### With Parallel Processing
```yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}
parallelism: 8 # Concurrent requests for speed
```
### Direct API Key (Not Recommended)
```yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: sk-your-api-key-here # Avoid committing secrets!
```
**Warning:** Never commit API keys to version control.
## Available Models
### text-embedding-3-small (Recommended)
| Property | Value |
|----------|-------|
| Dimensions | 1536 |
| Price | $0.00002 / 1K tokens |
| Quality | Very high |
| Speed | Fast |
**Best for:** Most use cases, good balance of cost/quality.
```yaml
embedder:
provider: openai
model: text-embedding-3-small
```
### text-embedding-3-large
| Property | Value |
|----------|-------|
| Dimensions | 3072 |
| Price | $0.00013 / 1K tokens |
| Quality | Highest |
| Speed | Fast |
**Best for:** Maximum accuracy, cost not a concern.
```yaml
embedder:
provider: openai
model: text-embedding-3-large
dimensions: 3072
```
### Dimension Reduction
You can reduce dimensions to save storage:
```yaml
embedder:
provider: openai
model: text-embedding-3-large
dimensions: 1024 # Reduced from 3072
```
## Model Comparison
| Model | Dimensions | Cost/1K tokens | Quality |
|-------|------------|----------------|---------|
| `text-embedding-3-small` | 1536 | $0.00002 | ⭐⭐⭐⭐ |
| `text-embedding-3-large` | 3072 | $0.00013 | ⭐⭐⭐⭐⭐ |
## Cost Estimation
Approximate costs per 1000 source files:
| Codebase Size | Chunks | Small Model | Large Model |
|---------------|--------|-------------|-------------|
| Small (100 files) | ~500 | $0.01 | $0.06 |
| Medium (1000 files) | ~5,000 | $0.10 | $0.65 |
| Large (10000 files) | ~50,000 | $1.00 | $6.50 |
**Note:** Costs are one-time for initial indexing. Updates only re-embed changed files.
## Optimizing for Speed
### Parallel Requests
GrepAI v0.24.0+ supports adaptive rate limiting and parallel requests:
```yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}
parallelism: 8 # Adjust based on your rate limit tier
```
Parallelism recommendations:
- **Tier 1 (Free):** 1-2
- **Tier 2:** 4-8
- **Tier 3+:** 8-16
### Batching
GrepAI automatically batches chunks for efficient API usage.
## Rate Limits
OpenAI has rate limits based on your account tier:
| Tier | RPM | TPM |
|------|-----|-----|
| Free | 3 | 150,000 |
| Tier 1 | 500 | 1,000,000 |
| Tier 2 | 5,000 | 5,000,000 |
GrepAI handles rate limiting automatically with adaptive backoff.
## Environment Variables
### Setting the API Key
**macOS/Linux:**
```bash
# In ~/.bashrc, ~/.zshrc, or ~/.profile
export OPENAI_API_KEY="sk-..."
```
**Windows (PowerShell):**
```powershell
$env:OPENAI_API_KEY = "sk-..."
# Or permanently
[System.Environment]::SetEnvironmentVariable('OPENAI_API_KEY', 'sk-...', 'User')
```
### Using .env Files
Create `.env` in your project root:
```
OPENAI_API_KEY=sk-...
```
Add to `.gitignore`:
```gitignore
.env
```
## Azure OpenAI
For Azure-hosted OpenAI:
```yaml
embedder:
provider: openai
model: your-deployment-name
api_key: ${AZURE_OPENAI_API_KEY}
endpoint: https://your-resource.openai.azure.com
```
## Security Best Practices
1. **Use environment variables:** Never hardcode API keys
2. **Add to .gitignore:** Exclude `.env` files
3. **Rotate keys:** Regularly rotate API keys
4. **Monitor usage:** Check OpenAI dashboard for unexpected usage
5. **Review code:** Ensure sensitive code isn't being indexed
## Common Issues
❌ **Problem:** `401 Unauthorized`
✅ **Solution:** Check API key is correct and environment variable is set:
```bash
echo $OPENAI_API_KEY
```
❌ **Problem:** `429 Rate limit exceeded`
✅ **Solution:** Reduce parallelism or upgrade OpenAI tier:
```yaml
embedder:
parallelism: 2 # Lower value
```
❌ **Problem:** High costs
✅ **Solutions:**
- Use `text-embedding-3-small` instead of large
- Reduce dimension size
- Add more ignore patterns to reduce indexed files
❌ **Problem:** Slow indexing
✅ **Solution:** Increase parallelism:
```yaml
embedder:
parallelism: 8
```
❌ **Problem:** Privacy concerns
✅ **Solution:** Use Ollama for local embeddings instead
## Migrating from Ollama to OpenAI
1. Update configuration:
```yaml
embedder:
provider: openai
model: text-embedding-3-small
api_key: ${OPENAI_API_KEY}
```
2. Delete existing index:
```bash
rm .grepai/index.gob
```
3. Re-index:
```bash
grepai watch
```
**Important:** You cannot mix embeddings from different models/providers.
## Output Format
Successful OpenAI configuration:
```
✅ OpenAI Embedding Provider Configured
Provider: OpenAI
Model: text-embedding-3-small
Dimensions: 1536
Parallelism: 4
API Key: sk-...xxxx (from environment)
Estimated cost for this codebase:
- Files: 245
- Chunks: ~1,200
- Cost: ~$0.02
Note: Code will be sent to OpenAI servers.
```
© yoanbernabeu · MIT · yoanbernabeu/grepai-skills