A unified FastAPI gateway for AI model services.
- Centralized API Key Management: Secure storage and retrieval
- Authentication: JWT-based authentication
- Model Proxies:
- OpenAI Chat Completions
- Hugging Face Text Generation
- Eleven Labs Text-to-Speech
- Vector Database Search
# Clone the repository
git clone <repository-url>
cd mcp-api
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn src.main:app --reload
Configure the following environment variables:
JWT_SECRET=your-secure-jwt-secret
ENCRYPTION_KEY=your-secure-encryption-key
KEYS_FILE=path/to/keys.json
You can also directly set API keys as environment variables:
OPENAI_API_KEY=your-openai-key
HUGGINGFACE_API_KEY=your-huggingface-key
ELEVENLABS_API_KEY=your-elevenlabs-key
Once the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
curl -X POST "http://localhost:8000/proxy/openai/chat" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"prompt":"What is the capital of France?", "model":"gpt-4o-mini"}'
curl -X POST "http://localhost:8000/proxy/elevenlabs/tts" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text":"Hello world", "voice_id":"EXAVITQu4vr4xnSDxMaL"}'
Add or update an API key:
curl -X PUT "http://localhost:8000/admin/keys/OPENAI_API_KEY" \
-H "Authorization: Bearer ADMIN_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"key":"your-openai-key", "service":"OPENAI_API_KEY"}'
List available keys:
curl -X GET "http://localhost:8000/admin/keys" \
-H "Authorization: Bearer ADMIN_JWT_TOKEN"
- In production, use proper secret management (AWS Secrets Manager, HashiCorp Vault, etc.)
- Rotate the JWT and encryption keys regularly
- Set up proper CORS restrictions for production environments
[Insert your license information here]