Skip to content

Repository files navigation

AI Studio

OpenAI-compatible API proxy with multi-provider failover, built with ASP.NET Core 10.0.

Features

  • OpenAI-compatible API — drop-in replacement for any OpenAI client
  • Multi-provider routing — auto-failover between OpenRouter, OllamaCloud, local LLMs
  • Combo system — group models with fallback or round-robin strategies
  • Tool call support — pass through OpenAI tool/function calling
  • Provider health tracking — cooldown on rate limits/errors, auto-recovery
  • Conversations & Scheduling — persistent chat history and scheduled tasks
  • Skills & Tools — extensible skill system with custom tool definitions
  • Embeddings — OpenAI-compatible embeddings endpoint
  • Usage tracking — per-request logging and usage analytics

Quick Start (Web Server)

# Configure providers in appsettings.json
# Set your API keys

# Run
cd src/AIStudio
dotnet run

# Test
curl http://localhost:5032/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hello"}]}'

Container

AI Studio ships as a Linux container on GitHub Container Registry (GHCR). The container serves both the Angular UI and ASP.NET Core API on port 8080, and stores writable application data under /data.

docker pull ghcr.io/dhhieu113pro/ai-studio:latest

docker run --rm \
  --name ai-studio \
  -p 8080:8080 \
  -v ai-studio-data:/data \
  ghcr.io/dhhieu113pro/ai-studio:latest

Open http://localhost:8080 after startup. Persist /data so SQLite databases, downloaded models, files, logs, and other runtime state survive container replacement.

The image includes ffmpeg and yt-dlp. Local LLM CPU execution is available inside the normal Linux container. GPU acceleration additionally depends on the host container runtime and compatible GPU drivers; for example, NVIDIA CUDA requires the NVIDIA Container Toolkit and a GPU-enabled docker run configuration.

Version tags publish multi-platform images for linux/amd64 and linux/arm64. A Git tag such as v0.2.0 publishes:

  • ghcr.io/dhhieu113pro/ai-studio:0.2.0
  • ghcr.io/dhhieu113pro/ai-studio:0.2
  • ghcr.io/dhhieu113pro/ai-studio:latest

GitHub Actions publishes tagged releases to GHCR using the repository GITHUB_TOKEN; no Docker Hub credentials are required. Pull requests and pushes to main build the image without publishing it.

API Endpoints

Controller Path Prefix Description
Chat /v1/chat/completions OpenAI-compatible chat completions
Models /v1/models List available models
Embeddings /v1/embeddings OpenAI-compatible embeddings
Conversations /api/conversations Persistent conversation history
Schedules /api/schedules Scheduled/recurring tasks
Skills /api/skills Skill definitions and management
Tools /api/tools Custom tool definitions
Config /api/config Runtime configuration
Logs /api/logs Request/response logs
Usage /api/usage Usage analytics
Response /api/response Response management
Mcp /api/mcp MCP server management
Test /api/test Diagnostic endpoints

Model Routing

  • model → tries all providers in priority order, falls back on error
  • providerId/modelName → targets a specific provider
  • all → combo that tries each model in the group sequentially

Configuration

See src/AIStudio/appsettings.json for all options:

  • Providers: id, name, apiKey, baseUrl, priority
  • Combos: grouped models with fallback or roundrobin strategy
  • Rate limit cooldown: automatic backoff per provider
  • SafeDownloads: allowed download sources
  • AllowedDownloadExtensions: file types permitted for download (.pdf, .txt, .md)
  • MaxToolIterate: maximum tool call iterations per request
  • GlobalSystemPrompt: system prompt applied to all requests

Modular Architecture

AI Studio is organized by functionality. Angular routes are lazy-loaded feature modules, while the ASP.NET host composes matching plugin projects with shared services from Core.

Module Angular route API surface Responsibility
OpenAI Compatible /openai /v1/* OpenAI-compatible API
Answers /answers Answers API Question and answer workflows
Chat /chat Chat/conversations API Interactive agent conversations
Skills /skills Skills API Skill definitions and execution context
Tools /tools Tools API Built-in and custom tools
MCP /mcp MCP API MCP servers and tool discovery
TTS /tts TTS provider API Speech providers and voices
Providers /providers Provider API Remote provider configuration and health
Local LLM /models Models API Model downloads and llama.cpp configuration
Video Composer /video-composer /api/video-composer/* Movies, scenes, rendering, media, music, films, knowledge, and publishing jobs; uses the shared app-root database by default
Video Downloader /video-composer/downloads /api/video-composer/downloads yt-dlp metadata lookup, queued downloads, progress, and output files
YouTube History /video-composer/youtube-history /api/video-composer/youtube-history Persistent discovered-video history and cleanup
Video Frames /video-composer /api/video-composer/frames Extract timestamp screenshots from workspace videos
Vietnamese Proverbs /video-composer/viet-proverbs /api/video-composer/viet-proverbs Provider-routed proverb lesson generation and video rendering
YouTube Channel Scan /video-composer/films /api/video-composer/youtube-scan/films/{filmId} Scan a configured film channel and record new matching videos
Automation /automation /api/automation/* Persistent crawl, trends, media-download jobs, and credential-gated browser adapters
Core shared auth, logs, usage, schedules, config Persistence and infrastructure

Module rules: features own their UI, controllers, services, and tests where practical; Core owns shared contracts, persistence, authentication, routing, scheduling, and infrastructure; Core must not depend on feature UI or controllers.

Feature projects currently extracted and registered through the plugin host are OpenAI Compatible, Chat, Answers, Skills, Tools, MCP, TTS, Providers, Local LLM, Video Composer, and Automation. Telegram remains an optional integration plugin. Shared runtime services such as provider routing and llama.cpp implementation remain in Core until their contracts can be separated without introducing a dependency cycle.

Video Composer is enabled by default in the publish scripts and is exposed at /video-composer. Supporting views are available under /video-composer/music, /video-composer/films, /video-composer/knowledge, /video-composer/publishing, /video-composer/image-magic, and /video-composer/quote-image. Its isolated database and workspace are configured under VideoComposer (FFmpeg paths, upload/output/music folders, and database path). Social provider credentials remain host-managed and are not copied from the legacy appsettings file. When VideoComposer:AutoDownloadFfmpeg is enabled, Windows downloads the FFmpeg GPL archive into the plugin workspace on first startup if no configured executable is available. Termux installs the architecture-matched FFmpeg package during publish-termux.sh; set AutoDownloadFfmpeg to false to disable bootstrap behavior.

Publishing

The publish scripts build the Angular UI, publish the API, and configure the target service. Core domains are always included. Interactive publishing only selects optional integrations:

Optional plugins to include (telegram, all, none) [all]: telegram

On Termux:

./publish-termux.sh

On Windows:

./publish-service.ps1

Project Structure

src/
  AIStudio.Core/          -- Core domain services and infrastructure
  AIStudio/               -- ASP.NET Core host and feature-grouped controllers
  Plugins/
    AIStudio.Abstractions/        -- Plugin contracts
    AIStudio.RunTime/             -- Plugin loading and registry
    AIStudio.Plugins.OpenAI/      -- OpenAI-compatible endpoints
    AIStudio.Plugins.Answers/     -- Answers endpoints
    AIStudio.Plugins.Chat/        -- Conversation runtime
    AIStudio.Plugins.Skills/      -- Skills endpoints
    AIStudio.Plugins.Tools/       -- Tools endpoints
    AIStudio.Plugins.Mcp/         -- MCP endpoints
    AIStudio.Plugins.Tts/         -- TTS endpoints and providers
    AIStudio.Plugins.Providers/   -- Provider endpoints
    AIStudio.Plugins.LocalLlm/    -- Local model endpoints
    AIStudio.Plugins.Telegram/    -- Optional Telegram integration
    AIStudio.Plugins.VideoComposer/-- Movie, media, and video rendering plugin
    AIStudio.Plugins.Automation/  -- Persistent automation jobs and adapters
ui/
  src/                    -- Angular frontend
tests/
  AIStudio.Tests/         -- xUnit tests

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages