Skip to content
/ Thor Public

Thor is a powerful artificial intelligence model management tool, whose main purpose is to achieve unified management and use of multiple AI models. Through Thor, users can easily manage and utilize numerous AI models

License

Notifications You must be signed in to change notification settings

AIDotNet/Thor

Repository files navigation

Thor - AI Model Management Gateway

License Stars Issues Docker

Thor is an enterprise-grade AI model management gateway that provides unified API access to manage and orchestrate multiple AI models. Compatible with OpenAI format, featuring comprehensive user management, channel management, billing, and monitoring capabilities.

πŸš€ Core Features

  • πŸ”§ Unified Management: Support for 20+ AI models with unified access and management
  • πŸ’° Smart Billing: Precise token-based billing system with cache optimization
  • πŸ“Š Real-time Monitoring: Detailed usage statistics and performance monitoring
  • πŸ” Access Control: Complete user management and access control system
  • ⚑ High Performance: Distributed caching and load balancing support
  • 🐳 Easy Deployment: One-click Docker deployment

πŸ“ˆ Data Visualization

Data Statistics Preview

πŸ“‹ Feature Overview

Core Features

  • βœ… User Management - Complete user registration, login, and permission control system
  • βœ… Channel Management - Unified access and management for multiple AI service providers
  • βœ… Token Management - API key generation, distribution, and permission control
  • βœ… Smart Billing - Accurate token billing with cache optimization support
  • βœ… Data Analytics - Real-time usage statistics and visual reports
  • βœ… Log Auditing - Complete API call logs and error tracking
  • βœ… System Configuration - Flexible system parameter configuration
  • βœ… Payment Integration - Alipay balance recharge functionality

Advanced Features

  • βœ… Cache Optimization - Redis distributed cache support
  • βœ… Load Balancing - Intelligent channel selection and failover
  • βœ… Rate Limiting - API rate limiting based on user groups
  • βœ… Real-time Monitoring - System performance and call monitoring
  • βœ… Multi-language Support - Chinese/English interface switching

πŸ€– Supported AI Models

OpenAI Compatible Models

  • βœ… OpenAI GPT Series (Function Calling supported)
  • βœ… Azure OpenAI (Function Calling supported)
  • βœ… Kimi (Moonshot AI) (Function Calling supported)
  • βœ… DeepSeek (Function Calling supported)
  • βœ… Claude (Anthropic) (Cache billing optimization supported)

Chinese AI Models

  • βœ… Baidu Wenxin Yiyan (ErnieBot) (Function Calling supported)
  • βœ… Alibaba Tongyi Qianwen (Function Calling supported)
  • βœ… Tencent Hunyuan (Function Calling supported)
  • βœ… Zhipu AI GLM Series (Function Calling supported)
  • βœ… iFlytek Spark Model (Function Calling supported)

Open Source Models

  • βœ… Ollama (Local deployment open source models)
  • βœ… SiliconFlow (Open source model aggregation platform)

Cloud Service Providers

  • βœ… Volcano Engine (ByteDance Cloud Services)
  • βœ… Amazon Bedrock (AWS AI Services)
  • βœ… Google Vertex AI (GCP AI Services)
  • βœ… Gitee AI (Gitee AI Platform)
  • βœ… MiniMax AI (SenseTime Technology)

πŸ—„οΈ Supported Databases

Database Type Configuration Value Description
SQLite sqlite Lightweight embedded database, default option
PostgreSQL postgresql / pgsql Enterprise-grade open source database
SQL Server sqlserver / mssql Microsoft enterprise database
MySQL mysql Most popular open source database
Dameng Database dm Chinese enterprise database

πŸ’‘ Modify the ConnectionStrings:DBType configuration in appsettings.json to switch database types. Database switching will not automatically migrate data.

πŸ—οΈ System Architecture

graph TB
    subgraph "User Layer"
        U[User/Client]
        U -->|API Key| T[Thor Gateway]
    end
    
    subgraph "Thor Core"
        T -->|Load Balancing| CM[Channel Management]
        T -->|Authentication| UM[User Management]
        T -->|Billing| BS[Billing System]
        T -->|Logging| LS[Log System]
    end
    
    subgraph "AI Service Providers"
        CM -->|OpenAI Format| O[OpenAI]
        CM -->|Azure Format| AZ[Azure OpenAI]
        CM -->|Claude Format| C[Anthropic]
        CM -->|Chinese APIs| CN[Baidu/Alibaba/Tencent]
        CM -->|Open Source| OS[Ollama/SiliconFlow]
    end
Loading

πŸš€ Quick Start

Prerequisites

  • Docker 20.10+
  • At least 1GB available memory
  • 500MB disk space

1. One-Click Docker Deployment

# Create data directory
mkdir -p ./data

# Start service
docker run -d \
  --name thor \
  -p 18080:8080 \
  -v $(pwd)/data:/data \
  -e TZ=Asia/Shanghai \
  -e DBType=sqlite \
  -e ConnectionStrings:DefaultConnection="data source=/data/token.db" \
  -e ConnectionStrings:LoggerConnection="data source=/data/logger.db" \
  -e RunMigrationsAtStartup=true \
  aidotnet/thor:latest

2. Access System

3. Configure Your First AI Channel

  1. Login to admin panel
  2. Go to "Channel Management" page
  3. Click "Create Channel"
  4. Select AI service provider and enter API key
  5. Save and test connection

πŸ“‹ Environment Variables

Variable Name Description Example Value
DBType Database type sqlite / postgresql / mysql / sqlserver
ConnectionStrings:DefaultConnection Main database connection string data source=/data/token.db
ConnectionStrings:LoggerConnection Log database connection string data source=/data/logger.db
CACHE_TYPE Cache type Memory / Redis
CACHE_CONNECTION_STRING Redis connection string localhost:6379
HttpClientPoolSize HTTP connection pool size 100
RunMigrationsAtStartup Run database migrations at startup true

🐳 Docker Compose Configuration

SQLite Version (Recommended for Beginners)

version: '3.8'
services:
  thor:
    image: aidotnet/thor:latest
    ports:
      - "18080:8080"
    volumes:
      - ./data:/data
    environment:
      - TZ=Asia/Shanghai
      - DBType=sqlite
      - ConnectionStrings:DefaultConnection=data source=/data/token.db
      - ConnectionStrings:LoggerConnection=data source=/data/logger.db
      - RunMigrationsAtStartup=true

PostgreSQL Version (Production Environment)

version: '3.8'
services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_DB: thor
      POSTGRES_USER: thor
      POSTGRES_PASSWORD: thor123
    volumes:
      - postgres_data:/var/lib/postgresql/data

  thor:
    image: aidotnet/thor:latest
    ports:
      - "18080:8080"
    depends_on:
      - postgres
    environment:
      - TZ=Asia/Shanghai
      - DBType=postgresql
      - ConnectionStrings:DefaultConnection=Host=postgres;Port=5432;Database=thor;Username=thor;Password=thor123
      - ConnectionStrings:LoggerConnection=Host=postgres;Port=5432;Database=thor_logger;Username=thor;Password=thor123
      - RunMigrationsAtStartup=true

volumes:
  postgres_data:

πŸ”§ Development Environment Setup

Prerequisites

  • .NET 8.0 SDK
  • Node.js 18+
  • Git

Local Development Steps

# Clone project
git clone https://github.com/AIDotNet/Thor.git
cd Thor

# Restore dependencies
dotnet restore

# Start backend service
cd src/Thor.Service
dotnet run --urls "http://localhost:5000"

# Start frontend dev server (new terminal)
cd lobe
npm install
npm run dev

πŸ“Š API Usage Examples

OpenAI Compatible Interface

# Chat completions
curl -X POST http://localhost:18080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# Text completions
curl -X POST http://localhost:18080/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "text-davinci-003",
    "prompt": "Once upon a time",
    "max_tokens": 100
  }'

πŸ› οΈ Troubleshooting

Q: How to reset admin password?

A: Delete user records in the database, the system will automatically recreate the default admin account.

Q: Which AI models are supported?

A: Supports all OpenAI compatible format models, including GPT-3.5, GPT-4, Claude, Wenxin Yiyan, etc.

Q: How to configure HTTPS?

A: It is recommended to use Nginx reverse proxy to configure HTTPS, Thor itself focuses on API gateway functionality.

Q: Will data be lost after switching databases?

A: Switching database types will not automatically migrate data, it is recommended to backup and manually migrate.

πŸ“ž Technical Support

🀝 Contributing

Welcome to submit Issues and Pull Requests to help improve Thor!

  1. Fork the project
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Create Pull Request

πŸ“„ License

This project is open source under the MIT License.

About

Thor is a powerful artificial intelligence model management tool, whose main purpose is to achieve unified management and use of multiple AI models. Through Thor, users can easily manage and utilize numerous AI models

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published