Skip to main content

OpenAI Compatible API

Enclava provides OpenAI-compatible endpoints for drop-in replacement with existing OpenAI clients.

What You'll Learn​

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​

ScenarioRecommendation
Simple chat completionsUse OpenAI API directly
Multi-turn conversationsUse OpenAI API directly
Custom workflowsUse OpenAI API directly
RAG-enhanced responsesUse Enclava RAG endpoints
Tool callingUse 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:

EndpointDescriptionOpenAI Compatible
GET /modelsList available models✓
GET /models/{model_id}Get model details✓
POST /chat/completionsGenerate chat completion✓
POST /embeddingsCreate 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​