Enterprise-grade ChatGPT API integration with conversation management, caching, and monitoring built with .NET 8
IntelliBot API is a production-ready .NET 8 Web API for integrating OpenAI's ChatGPT into your applications. It provides advanced features like conversation memory, Redis caching, rate limiting, and real-time streaming for building intelligent chatbot applications and AI-powered solutions.
🔥 Perfect for: Chat applications, AI assistants, customer support bots, and enterprise AI solutions
- Multi-Model Support: GPT-3.5 Turbo, GPT-4, GPT-4 Turbo, GPT-4o
- Conversation Management: Persistent chat history with context awareness
- Streaming Responses: Real-time token streaming for better UX
- Smart Caching: Redis-powered response caching to reduce API costs
- Rate Limiting: Configurable request throttling per user/IP
- Resilience Patterns: Polly retry policies and circuit breakers
- Structured Logging: Serilog with JSON formatting for observability
- API Documentation: Auto-generated Swagger/OpenAPI with examples
- Validation: FluentValidation for robust request validation
- Usage Statistics: Token tracking and cost estimation
- Performance Metrics: Response times and error rate monitoring
- Health Checks: Comprehensive service health monitoring
| Category | Technologies |
|---|---|
| Backend | .NET 8, ASP.NET Core, Entity Framework Core |
| Database | PostgreSQL, Redis |
| AI/ML | OpenAI API, ChatGPT Integration |
| DevOps | Docker, Serilog, Polly, FluentValidation |
| API | RESTful, Swagger/OpenAPI, AutoMapper |
IntelliBotAPI/
├── 🎯 IntelliBot.API/ # Controllers, DTOs, Configuration
├── 🧠 IntelliBot.Application/ # Services, Validators, Business Logic
├── 💾 IntelliBot.Infrastructure/ # Repositories, External APIs, Caching
├── 📦 IntelliBot.Core/ # Entities, Interfaces, Enums
└── 🔧 IntelliBot.Shared/ # Utilities, Extensions, Constants
- .NET 8 SDK
- PostgreSQL 14+
- Redis 6+
- OpenAI API Key
- Clone and setup
git clone https://github.com/yourusername/IntelliBotAPI.git
cd IntelliBotAPI/src/IntelliBot.API- Configure environment
Update
appsettings.Development.json:
{
"OpenAI": {
"ApiKey": "your-openai-api-key",
"DefaultModel": "gpt-3.5-turbo"
},
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=IntelliBot;Username=postgres;Password=yourpassword",
"Redis": "localhost:6379"
}
}- Run database migrations
dotnet ef database update- Run the application
dotnet run- API: https://localhost:7131
- Swagger UI: https://localhost:7131/swagger
- Health Check: https://localhost:7131/health
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/chat/message |
Send chat message |
| POST | /api/chat/message/stream |
Stream chat response |
| GET | /api/chat/conversations |
List conversations |
| GET | /api/chat/conversations/{id} |
Get conversation |
| POST | /api/chat/conversations |
Create conversation |
| DELETE | /api/chat/conversations/{id} |
Delete conversation |
| GET | /api/chat/models |
Get available AI models |
| GET | /api/chat/usage |
Get usage statistics |
curl -X POST "https://localhost:7131/api/chat/message" \
-H "Content-Type: application/json" \
-d '{
"message": "Explain quantum computing in simple terms",
"model": 1,
"temperature": 0.7
}'docker-compose up -d| Variable | Description | Default |
|---|---|---|
OpenAI__ApiKey |
OpenAI API Key | Required |
OpenAI__DefaultModel |
Default AI model | gpt-3.5-turbo |
ConnectionStrings__DefaultConnection |
PostgreSQL connection | Required |
ConnectionStrings__Redis |
Redis connection | localhost:6379 |
Serilog__MinimumLevel |
Logging level | Information |
Configure in appsettings.json:
{
"RateLimiting": {
"RequestsPerMinute": 10,
"RequestsPerHour": 100,
"RequestsPerDay": 1000
}
}dotnet builddotnet test- EditorConfig for consistent code style
- XML Documentation for public APIs
- Async/Await pattern throughout
{
"Timestamp": "2025-10-18T12:00:00Z",
"Level": "Information",
"Message": "Chat request processed",
"Properties": {
"ProcessingTimeMs": 1250,
"TokensUsed": 150,
"Model": "gpt-3.5-turbo",
"ConversationId": "conv-123"
}
}- Overall health: GET
/health - Database health: GET
/health/ready - External services: GET
/health/live
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for the ChatGPT API
- .NET Team for the excellent framework
- All contributors and users of this project
If you find this project helpful, please give it a ⭐