FastAPI AI Chatbot API (Ollama + OpenAI)
A powerful REST API for AI chatbot built with FastAPI. Supports both Ollama (local, free) and OpenAI (cloud) as AI providers.
🔥 Features:
✔ REST API with automatic Swagger documentation
✔ Ollama support — local, free, no internet required
✔ OpenAI support — GPT-3.5/GPT-4
✔ Streaming responses (Server-Sent Events)
✔ Conversation history per session
✔ Multiple model support
✔ CORS enabled for browser access
✔ Health check endpoint
📦 API Endpoints:
✔ POST /chat — Send message, get AI response
✔ POST /chat/stream — Real-time streaming response
✔ GET /models — List available models
✔ GET /history/{session_id} — Conversation history
✔ DELETE /history/{session_id} — Clear history
✔ GET /health — Health check
✔ GET /docs — Swagger UI (automatic!)
📦 What you get:
✔ Full Python source code
✔ Step-by-step setup instructions
✔ Swagger API documentation (auto-generated)
✔ README.md documentation
🛠Setup takes less than 5 minutes!
GitHub: https://github.com/Firoj0044/fastapi-ai-chatbot