CBAI - Unified AI Provider Service¶
Unified API for multiple AI providers with automatic fallback routing.
Overview¶
CBAI provides a single API interface to multiple AI providers:
| Provider | Use Case | Models |
|---|---|---|
| Claude (Anthropic) | Chat, summarization, analysis | claude-sonnet-4-5-20250929 |
| Ollama (Local) | Chat, embeddings, vision, code | mistral-small3.2, nomic-embed-text |
| Mistral | OCR, document processing | mistral-ocr-latest |
| Unstructured | Document parsing | various |
API Endpoints¶
Core AI Operations¶
| Endpoint | Method | Description |
|---|---|---|
/api/v1/chat |
POST | Chat with any provider |
/api/v1/embed |
POST | Generate vector embeddings (768-dim) |
/api/v1/summarize |
POST | Summarize text |
/api/v1/topics |
POST | Extract topics from content |
/api/v1/ocr |
POST | OCR with Mistral |
/api/v1/ocr/unstructured |
POST | Document parsing |
Usage Tracking¶
| Endpoint | Method | Description |
|---|---|---|
/api/v1/usage |
GET | Query usage records with filters |
/api/v1/usage/summary |
GET | Aggregated statistics |
/api/v1/usage/{request_id} |
GET | Single record by ID |
/api/v1/usage/{request_id} |
DELETE | Delete a record |
Discovery & Health¶
| Endpoint | Method | Description |
|---|---|---|
/api/v1/health |
GET | Provider status check |
/model-cards.json |
GET | Ollama model catalog |
Provider Fallback Logic¶
The AI manager routes operations with automatic fallback:
- Chat: Claude (if key) -> Ollama
- Embeddings: Always Ollama (384-dim for pgvector)
- OCR: Mistral for PDFs, Unstructured for documents
- Summarize: Claude (quality) or Ollama (speed)
Configuration¶
Environment variables:
# Ollama (local)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_CHAT_MODEL=mistral-small3.2:latest
OLLAMA_EMBEDDING_MODEL=gemma:2b
# Anthropic
CLAUDE_API_KEY=sk-ant-...
CLAUDE_MODEL=claude-sonnet-4-5-20250929
# Mistral
MISTRAL_API_KEY=...
MISTRAL_OCR_MODEL=mistral-ocr-latest
Developer Resources¶
- CLAUDE.md - AI-assisted development guide
- GitHub Repository