OpenAI Embeddings
Configure OpenAI embedding models
Configuration
embedding_model:
provider: "openai"
api_key: $OPENAI_API_KEY
model: "text-embedding-ada-002"
base_url: null
Configuration Options
Field | Type | Default | Required | Description |
---|---|---|---|---|
provider | string | - | ✅ | Must be "openai" |
api_key | string | - | ✅ | OpenAI API key |
model | string | "text-embedding-ada-002" | ❌ | Model name |
base_url | string | null | ❌ | Optional custom URL |
rpm | integer | 3000 | ❌ | Requests per minute |
tpm | integer | 1000000 | ❌ | Tokens per minute |
Setup
- Create OpenAI account: platform.openai.com
- Generate API key: API Keys
- Add to environment:
OPENAI_API_KEY=sk-...
Configuration Parameters
Parameter | Description | Required | Default |
---|---|---|---|
provider | Must be openai | ✓ | - |
api_key | OpenAI API key | ✓ | - |
model | Name of the embedding model | ✗ | text-embedding-ada-002 |
base_url | Alternative API URL (for proxies) | ✗ | https://api.openai.com/v1 |
rpm | Maximum API requests per minute | ✗ | 3000 |
tpm | Maximum tokens per minute | ✗ | 1000000 |
Available Models
text-embedding-3-small
- Dimensions: 1536
- Cost: ~$0.00002/1K tokens
- Usage: Cost-effective, good for most applications
text-embedding-3-large
- Dimensions: 3072
- Cost: ~$0.00013/1K tokens
- Usage: Highest quality, for demanding applications
text-embedding-ada-002 (Legacy)
- Dimensions: 1536
- Cost: ~$0.0001/1K tokens
- Usage: Proven, gradually being replaced by newer models
Example Configuration
Standard Setup
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-small
With Custom Base URL (Proxy)
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-small
base_url: https://your-proxy.company.com/v1
With Rate Limiting
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-large
rpm: 1000 # Reduced requests per minute
tpm: 500000 # Reduced tokens per minute
Legacy Model
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-ada-002
API Key Setup
1. Create OpenAI Account
Visit platform.openai.com
Create an account or log in
Navigate to API Keys
Click "Create new secret key"
Enter a name and copy the API key
2. Environment Variables
Define in your vault.env
file:
# OpenAI API
OPENAI_API_KEY=sk-...
Security: Never share your API key publicly or commit it to Git repositories. Always use environment variables.
Cost Optimization
Configure Rate Limiting
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-small
rpm: 500 # Reduced requests for cost control
tpm: 100000 # Fewer tokens per minute
Model Selection
Scenario | Recommended Model | Reason |
---|---|---|
Cost-sensitive | text-embedding-3-small | Best cost-benefit ratio |
Highest quality | text-embedding-3-large | Best performance |
Existing integration | text-embedding-ada-002 | Proven and stable |
Monitoring and Limits
OpenAI Usage Dashboard
Monitor your usage via:
- OpenAI Usage Dashboard
- API costs and token consumption
- Rate limits and quotas
Typical Limits (as of 2024)
Model | Rate Limit | Context Limit |
---|---|---|
text-embedding-3-small | 3000 RPM | 8191 tokens |
text-embedding-3-large | 3000 RPM | 8191 tokens |
text-embedding-ada-002 | 3000 RPM | 8191 tokens |
Troubleshooting
Common Issues
Debug Configuration
For detailed logs:
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-small
# Reduced limits for testing
rpm: 10
tpm: 1000
Performance Tips
Batch Processing
The DataVault processes multiple texts simultaneously for better efficiency
Cost Monitoring
Regularly monitor your OpenAI usage in the dashboard
API Key Rotation
Rotate API keys regularly for better security
Migration from Legacy Models
From ada-002 to text-embedding-3-small
# Old
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-ada-002
# New
embedding_model:
provider: openai
api_key: $OPENAI_API_KEY
model: text-embedding-3-small
Reindexing required: After a model change, all documents must be reindexed. Plan for appropriate downtime.
Enterprise Features
Dedicated Instances
For large enterprises, OpenAI offers dedicated instances:
- Guaranteed capacity
- Lower latency
- Customized rate limits
Compliance
OpenAI meets various compliance standards:
- GDPR: General Data Protection Regulation
- SOC 2: Service Organization Control 2
- Others: Depending on region and plan