# AI-DPI Middleware
> **Developed and maintained by Data Science Nigeria**
An open, model-agnostic AI middleware layer for **Digital Public Infrastructure (DPI)**. Delivers LLM chat, RAG document intelligence, speech, translation, and structured extraction through a single secure FastAPI gateway – with plug-and-play provider switching and no vendor lock-in.
---
## Features
| Capability | Providers |
| --------------------------------- | --------------------------------------------------------------------------------------- |
| **LLM Chat + Streaming** | Anthropic, OpenAI, Groq, Gemini, Generic OpenAI-compatible,**Ollama (sovereign)** |
| **RAG Ingestion** | PDF, DOCX, PPTX, XLSX, CSV, RTF, ODT, TXT, MD – OCR for scanned docs |
| **Structured Extraction** | JSON Schema-constrained field extraction, provider-native structured output |
| **Translation** | LLM-backed, 100+ languages including African low-resource languages |
| **Speech-to-Text** | Groq Whisper, OpenAI Whisper, Deepgram Nova-3, Spitch, Intron Sahara |
| **Text-to-Speech** | Groq PlayAI/Orpheus, OpenAI, ElevenLabs, Spitch, Intron Sahara |
| **Embeddings** | OpenAI (cloud), sentence-transformers**(sovereign, no API key)** |
| **Vector DB** | Weaviate (open-source), Qdrant (open-source), Pinecone (managed) |
| **Auth** | Local JWT (HS256), OIDC RS256/ES256 (Keycloak, Auth0, Google), Token Introspection |
| **Session History** | Redis-backed multi-turn conversation history with configurable TTL |
| **Caching + Rate Limiting** | Redis – per-role limits on every endpoint |
| **Audit** …