OpenAI Compatible API
Enclava provides OpenAI-compatible endpoints for drop-in replacement with existing OpenAI clients.
What You'll Learn
- Models - List and retrieve available models
- Chat Completions - Generate text completions
- Embeddings - Create text embeddings
- Integrations - Use with various frameworks
Why OpenAI Compatibility?
Benefits
- Zero Code Changes - Most OpenAI clients only need a base URL change
- Familiar API - Same request/response format as OpenAI
- Framework Support - Works with LangChain, LlamaIndex, and more
- Gradual Migration - Switch incrementally, test as you go
When to Use OpenAI API
| Scenario | Recommendation |
|---|---|
| Simple chat completions | Use OpenAI API directly |
| Multi-turn conversations | Use OpenAI API directly |
| Custom workflows | Use OpenAI API directly |
| RAG-enhanced responses | Use Enclava RAG endpoints |
| Tool calling | Use Enclava agent endpoints |
Base URL Configuration
Standard OpenAI
openai.api_base = "https://api.openai.com/v1"
Enclava (Change Only This)
openai.api_base = "https://your-enclava-instance/api/v1"
All other code remains the same!
Supported Endpoints
Enclava implements these OpenAI endpoints:
| Endpoint | Description | OpenAI Compatible |
|---|---|---|
GET /models | List available models | ✓ |
GET /models/{model_id} | Get model details | ✓ |
POST /chat/completions | Generate chat completion | ✓ |
POST /embeddings | Create embeddings | ✓ |
Authentication
OpenAI uses API keys - Enclava uses the same pattern:
# OpenAI
Authorization: Bearer sk-...
# Enclava
Authorization: Bearer en_...
Just replace your OpenAI key with an Enclava API key!
Pricing Model
Enclava uses the same model names and pricing structure as OpenAI, with your negotiated rates applied. Usage is tracked per API key with budget enforcement.
Next Steps
- List Models - See what's available
- Chat Completions - Start generating text
- Integration Examples - Use with Python clients