Skip to content

🎬 Open-source, self-hosted AI agent that runs a YouTube channel end to end: researches topics, writes scripts, generates narration, visuals and video, optimizes SEO, and publishes after your approval, then learns from analytics. Works with Gemini, OpenAI, OpenRouter, DeepSeek and more.

Add multi-provider support: OpenRouter, Kimi, MiMo, GLM

darkzOGx493d9c15c4ff
diff --git a/.env.example b/.env.example
index 63dec8a..bf4b10c 100644
--- a/.env.example
+++ b/.env.example
@@ -1,9 +1,13 @@
# YouTube Automation Agent Environment Configuration
# Copy this file to .env and fill in your actual values
-# AI Provider - Choose one or both
+# AI Provider - Pick one (or use OpenRouter for access to all)
OPENAI_API_KEY=your-openai-api-key-here
+# OPENROUTER_API_KEY=your-openrouter-api-key-here
# GEMINI_API_KEY=your-gemini-api-key-here
+# MOONSHOT_API_KEY=your-kimi-api-key-here
+# MIMO_API_KEY=your-mimo-api-key-here
+# GLM_API_KEY=your-glm-api-key-here
# ElevenLabs TTS (optional, higher quality than OpenAI TTS)
# ELEVENLABS_API_KEY=your-elevenlabs-api-key-here
diff --git a/README.md b/README.md
index e8470a6..35a351b 100644
--- a/README.md
+++ b/README.md
@@ -43,25 +43,34 @@ Each agent handles one stage of the pipeline:
## AI Providers
-### OpenAI (recommended)
+All OpenAI-compatible providers work out of the box β€” the system auto-configures the SDK base URL. Pick one, or use OpenRouter to access everything through a single key.
-- **Language**: GPT-5.5 / GPT-5.5 Instant
-- **Images**: GPT Image 2
-- **TTS**: GPT-4o-mini-tts
-- **Cost**: ~$0.05–0.20 per video
-
-### Google Gemini (free tier)
-
-- **Language**: Gemini 3.5 Flash / Gemini 3.5 Pro
-- **Cost**: Free for most usage volumes
+```mermaid
+graph LR
+ subgraph Direct
+ OA[OpenAI<br/>GPT-5.5]
+ GM[Gemini<br/>3.5 Flash/Pro]
+ KM[Kimi<br/>K2.6]
+ MM[MiMo<br/>V2.5 Pro]
+ GL[GLM<br/>GLM-5]
+ end
+ subgraph Router
+ OR[OpenRouter<br/>300+ models]
+ end
+ Direct --> YAA[YouTube Automation Agent]
+ Router --> YAA
+```
-### Other integrations
+| Provider | Models | Base URL | Cost |
+|----------|--------|----------|------|
+| **OpenAI** | GPT-5.5, GPT-5.5 Instant | `api.openai.com/v1` | ~$0.05–0.20/video |
+| **OpenRouter** | 300+ (GPT, Claude, Gemini, Kimi, GLM, etc.) | `openrouter.ai/api/v1` | varies by model |
+| **Google Gemini** | Gemini 3.5 Flash, 3.5 Pro | via `@google/genai` SDK | free tier available |
+| **Kimi (Moonshot AI)** | Kimi K2.6, K2.5 | `api.moonshot.ai/v1` | ~80% cheaper than GPT-5.5 |
+| **MiMo (Xiaomi)** | MiMo V2.5 Pro, V2.5 | `api.xiaomimimo.com/v1` | competitive |
+| **GLM (Zhipu AI)** | GLM-5, GLM-5.1 | `api.z.ai/api/paas/v4/` | ~$1/M input tokens |
-- Anthropic Claude (`claude-opus-4-8`, `claude-haiku-4-5`)
-- ElevenLabs (premium TTS with Eleven v3)
-- Replicate (Wan 2.7 video generation)
-- Local models via Ollama
-- Any OpenAI-compatible API
+Additional integrations: Anthropic Claude (`claude-opus-4-8`), ElevenLabs (Eleven v3 TTS), Replicate (Wan 2.7 video), local models via Ollama, any OpenAI-compatible endpoint.
## Quick Start
@@ -99,17 +108,34 @@ Dashboard runs at `http://localhost:3456`.
1. Get a key from [platform.openai.com](https://platform.openai.com/)
2. Set `OPENAI_API_KEY` in `.env`
+#### OpenRouter (easiest β€” one key, all models)
+
+1. Get a key from [openrouter.ai/keys](https://openrouter.ai/keys)
+2. Set `OPENROUTER_API_KEY` in `.env`
+
#### Google Gemini
1. Get a key from [Google AI Studio](https://aistudio.google.com/)
2. Set `GEMINI_API_KEY` in `.env`
+#### Kimi / MiMo / GLM
+
+| Provider | Get key at | Env var |
+|----------|-----------|---------|
+| Kimi (Moonshot AI) | [platform.kimi.ai](https://platform.kimi.ai) | `MOONSHOT_API_KEY` |
+| MiMo (Xiaomi) | [mimo.mi.com](https://mimo.mi.com) | `MIMO_API_KEY` |
+| GLM (Zhipu AI) | [z.ai](https://z.ai) | `GLM_API_KEY` |
+
### Environment Variables
```env
-# AI providers (pick one or both)
+# AI provider β€” pick one (or use OpenRouter for access to all)
OPENAI_API_KEY=sk-...
+# OPENROUTER_API_KEY=sk-or-...
# GEMINI_API_KEY=...
+# MOONSHOT_API_KEY=...
+# MIMO_API_KEY=...
+# GLM_API_KEY=...
# Optional: premium TTS
# ELEVENLABS_API_KEY=...
@@ -284,7 +310,11 @@ MIT β€” see [LICENSE](LICENSE).
## Acknowledgments
- [OpenAI](https://openai.com/) β€” GPT-5.5, GPT Image 2, GPT-4o-mini-tts
+- [OpenRouter](https://openrouter.ai/) β€” unified multi-model API
- [Google](https://ai.google.dev/) β€” YouTube Data API, Gemini 3.5
+- [Moonshot AI](https://www.moonshot.ai/) β€” Kimi K2.6
+- [Xiaomi](https://mimo.mi.com/) β€” MiMo V2.5
+- [Zhipu AI](https://z.ai/) β€” GLM-5
- [ElevenLabs](https://elevenlabs.io/) β€” Eleven v3 TTS
- [Replicate](https://replicate.com/) β€” Wan 2.7 video generation
diff --git a/utils/ai-text-service.js b/utils/ai-text-service.js
new file mode 100644
index 0000000..89a061a
--- /dev/null
+++ b/utils/ai-text-service.js
@@ -0,0 +1,129 @@
+const OpenAI = require('openai');
+const { Logger } = require('./logger');
+
+const PROVIDERS = {
+ openai: {
+ name: 'OpenAI',
+ baseURL: 'https://api.openai.com/v1',
+ defaultModel: 'gpt-5.5',
+ models: ['gpt-5.5', 'gpt-5.5-instant', 'gpt-5.4'],
+ envKey: 'OPENAI_API_KEY',
+ },
+ openrouter: {
+ name: 'OpenRouter',
+ baseURL: 'https://openrouter.ai/api/v1',
+ defaultModel: 'openai/gpt-5.5',
+ models: ['openai/gpt-5.5', 'anthropic/claude-opus-4-8', 'google/gemini-3.5-flash', 'moonshotai/kimi-k2.6', 'zhipu/glm-5'],
+ envKey: 'OPENROUTER_API_KEY',
+ },
+ kimi: {
+ name: 'Kimi (Moonshot AI)',
+ baseURL: 'https://api.moonshot.ai/v1',
+ defaultModel: 'kimi-k2.6',
+ models: ['kimi-k2.6', 'kimi-k2.5', 'moonshot-v1-auto'],
+ envKey: 'MOONSHOT_API_KEY',
+ },
+ mimo: {
+ name: 'MiMo (Xiaomi)',
+ baseURL: 'https://api.xiaomimimo.com/v1',
+ defaultModel: 'mimo-v2.5-pro',
+ models: ['mimo-v2.5-pro', 'mimo-v2.5'],
+ envKey: 'MIMO_API_KEY',
+ },
+ glm: {
+ name: 'GLM (Zhipu AI)',
+ baseURL: 'https://api.z.ai/api/paas/v4/',
+ defaultModel: 'glm-5',
+ models: ['glm-5', 'glm-5.1'],
+ envKey: 'GLM_API_KEY',
+ },
+};
+
+class AITextService {
+ constructor(credentials = {}) {
+ this.logger = new Logger('AITextService');
+ this.client = null;
+ this.gemini = null;
+ this.model = null;
+ this.providerName = null;
+
+ this._init(credentials);
+ }
+
+ _init(credentials) {
+ const provider = credentials.aiProvider?.provider;
+ const apiKey = credentials.aiProvider?.apiKey;
+ const model = credentials.aiProvider?.model;
+
+ if (provider && PROVIDERS[provider] && apiKey) {
+ return this._initOpenAICompatible(PROVIDERS[provider], apiKey, model);
+ }
+
+ for (const [, preset] of Object.entries(PROVIDERS)) {
+ const key = process.env[preset.envKey];
+ if (key) {
+ return this._initOpenAICompatible(preset, key);
+ }
+ }
+
+ const geminiKey = credentials.gemini?.apiKey || process.env.GEMINI_API_KEY;
+ if (geminiKey) {
+ return this._initGemini(geminiKey, credentials.gemini?.model);
+ }
+
+ this.logger.warn('No AI text provider configured β€” text generation unavailable');
+ }
+
+ _initOpenAICompatible(preset, apiKey, model) {
+ this.client = new OpenAI({ apiKey, baseURL: preset.baseURL });
+ this.model = model || preset.defaultModel;
+ this.providerName = preset.name;
+ this.logger.info(`${preset.name} initialized (model: ${this.model})`);
+ }
+
+ _initGemini(apiKey, model) {
+ try {
+ const { GoogleGenAI } = require('@google/genai');
+ this.gemini = new GoogleGenAI({ apiKey });
+ this.model = model || 'gemini-3.5-flash';
+ this.providerName = 'Google Gemini';
+ this.logger.info(`Gemini initialized (model: ${this.model})`);
+ } catch (error) {
+ this.logger.error('Failed to initialize Gemini:', error.message);
+ }
+ }
+
+ async generateText(prompt, options = {}) {
+ const model = options.model || this.model;
+ const maxTokens = options.maxTokens || 2048;
+ const temperature = options.temperature ?? 0.7;
+
+ if (this.gemini) {
+ const response = await this.gemini.models.generateContent({
+ model,
+ contents: prompt,
+ config: { maxOutputTokens: maxTokens, temperature },
+ });
+ return response.text;
+ }
+
+ if (!this.client) {
+ throw new Error('No AI text provider configured');
+ }
+
+ const response = await this.client.chat.completions.create({
+ model,
+ messages: [{ role: 'user', content: prompt }],
+ max_tokens: maxTokens,
+ temperature,
+ });
+
+ return response.choices[0].message.content;
+ }
+
+ isAvailable() {
+ return !!(this.client || this.gemini);
+ }
+}
+
+module.exports = { AITextService, PROVIDERS };
diff --git a/utils/credential-manager.js b/utils/credential-manager.js
index 9ca0e61..f698540 100644
--- a/utils/credential-manager.js
+++ b/utils/credential-manager.js
@@ -221,6 +221,137 @@ class CredentialManager {
console.log(chalk.green('βœ… Gemini credentials configured successfully!'));
}
+ // OpenRouter Setup
+ async setupOpenRouterCredentials() {
+ console.log(chalk.cyan('\nOpenRouter Setup'));
+ console.log(chalk.gray('Get your API key from: https://openrouter.ai/keys'));
+ console.log(chalk.gray('One key gives access to 300+ models (OpenAI, Claude, Gemini, Kimi, GLM, etc.)'));
+
+ const answers = await inquirer.prompt([
+ {
+ type: 'password',
+ name: 'apiKey',
+ message: 'Enter your OpenRouter API Key:',
+ validate: input => input.startsWith('sk-or-') || 'Invalid OpenRouter key format (starts with sk-or-)'
+ },
+ {
+ type: 'list',
+ name: 'model',
+ message: 'Select default model:',
+ choices: [
+ 'openai/gpt-5.5',
+ 'anthropic/claude-opus-4-8',
+ 'google/gemini-3.5-flash',
+ 'moonshotai/kimi-k2.6',
+ 'zhipu/glm-5'
+ ],
+ default: 'openai/gpt-5.5'
+ }
+ ]);
+
+ this.credentials.aiProvider = {
+ provider: 'openrouter',
+ apiKey: answers.apiKey,
+ model: answers.model
+ };
+
+ await this.saveCredentials();
+ console.log(chalk.green('OpenRouter configured successfully!'));
+ }
+
+ // Kimi (Moonshot AI) Setup
+ async setupKimiCredentials() {
+ console.log(chalk.cyan('\nKimi (Moonshot AI) Setup'));
+ console.log(chalk.gray('Get your API key from: https://platform.kimi.ai'));
+
+ const answers = await inquirer.prompt([
+ {
+ type: 'password',
+ name: 'apiKey',
+ message: 'Enter your Moonshot API Key:',
+ validate: input => input.length > 0 || 'API key is required'
+ },
+ {
+ type: 'list',
+ name: 'model',
+ message: 'Select model:',
+ choices: ['kimi-k2.6', 'kimi-k2.5', 'moonshot-v1-auto'],
+ default: 'kimi-k2.6'
+ }
+ ]);
+
+ this.credentials.aiProvider = {
+ provider: 'kimi',
+ apiKey: answers.apiKey,
+ model: answers.model
+ };
+
+ await this.saveCredentials();
+ console.log(chalk.green('Kimi credentials configured successfully!'));
+ }
+
+ // MiMo (Xiaomi) Setup
+ async setupMiMoCredentials() {
+ console.log(chalk.cyan('\nMiMo (Xiaomi) Setup'));
+ console.log(chalk.gray('Get your API key from: https://mimo.mi.com'));
+
+ const answers = await inquirer.prompt([
+ {
+ type: 'password',
+ name: 'apiKey',
+ message: 'Enter your MiMo API Key:',
+ validate: input => input.length > 0 || 'API key is required'
+ },
+ {
+ type: 'list',
+ name: 'model',
+ message: 'Select model:',
+ choices: ['mimo-v2.5-pro', 'mimo-v2.5'],
+ default: 'mimo-v2.5-pro'
+ }
+ ]);
+
+ this.credentials.aiProvider = {
+ provider: 'mimo',
+ apiKey: answers.apiKey,
+ model: answers.model
+ };
+
+ await this.saveCredentials();
+ console.log(chalk.green('MiMo credentials configured successfully!'));
+ }
+
+ // GLM (Zhipu AI) Setup
+ async setupGLMCredentials() {
+ console.log(chalk.cyan('\nGLM (Zhipu AI) Setup'));
+ console.log(chalk.gray('Get your API key from: https://z.ai'));
+
+ const answers = await inquirer.prompt([
+ {
+ type: 'password',
+ name: 'apiKey',
+ message: 'Enter your GLM API Key:',
+ validate: input => input.length > 0 || 'API key is required'
+ },
+ {
+ type: 'list',
+ name: 'model',
+ message: 'Select model:',
+ choices: ['glm-5', 'glm-5.1'],
+ default: 'glm-5'
+ }
+ ]);
+
+ this.credentials.aiProvider = {
+ provider: 'glm',
+ apiKey: answers.apiKey,
+ model: answers.model
+ };
+
+ await this.saveCredentials();
+ console.log(chalk.green('GLM credentials configured successfully!'));
+ }
+
// Azure Speech Services (TTS)
async setupAzureSpeechCredentials() {
console.log(chalk.cyan('\nπŸŽ™οΈ Azure Speech Services Setup'));
@@ -485,18 +616,22 @@ class CredentialManager {
message: 'Select your preferred AI service:',
choices: [
{ name: 'OpenAI (GPT-5.5)', value: 'openai' },
- { name: 'Google Gemini (Gemini 3.5)', value: 'gemini' },
- { name: 'Both (OpenAI primary)', value: 'both' }
+ { name: 'Google Gemini (Gemini 3.5 β€” free tier)', value: 'gemini' },
+ { name: 'OpenRouter (300+ models, one API key)', value: 'openrouter' },
+ { name: 'Kimi (Moonshot AI β€” K2.6)', value: 'kimi' },
+ { name: 'MiMo (Xiaomi β€” V2.5 Pro)', value: 'mimo' },
+ { name: 'GLM (Zhipu AI β€” GLM-5)', value: 'glm' },
]
}
]);
- if (service === 'openai' || service === 'both') {
- await this.setupOpenAICredentials();
- }
-
- if (service === 'gemini' || service === 'both') {
- await this.setupGeminiCredentials();
+ switch (service) {
+ case 'openai': return await this.setupOpenAICredentials();
+ case 'gemini': return await this.setupGeminiCredentials();
+ case 'openrouter': return await this.setupOpenRouterCredentials();
+ case 'kimi': return await this.setupKimiCredentials();
+ case 'mimo': return await this.setupMiMoCredentials();
+ case 'glm': return await this.setupGLMCredentials();
}
}